Skip to content

Commit eecfb5c

Browse files
committed
Rename float_format to decimal_format
1 parent 3d5cf30 commit eecfb5c

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/m3u8/attribute_formatter.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def boolean_format(key, value)
2929
"#{key}=#{value == true ? 'YES' : 'NO'}" unless value.nil?
3030
end
3131

32-
# Format a float attribute, ensuring it formatted as a floating-point number
33-
# or integer
34-
# @param number [Float, Integer] the number to format
35-
# @return [String] formatted number as a string
36-
def float_format(number)
32+
# Format a decimal attribute, ensuring it formatted as a floating-point
33+
# number or integer
34+
# @param number [Float, Integer, nil] the number to format
35+
# @return [String, nil] formatted string or nil when value is nil
36+
def decimal_format(number)
3737
case number
3838
when nil
3939
nil

lib/m3u8/date_range_item.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def formatted_attributes
131131
quoted_format('CLASS', class_name),
132132
%(START-DATE="#{start_date}"),
133133
quoted_format('END-DATE', end_date),
134-
unquoted_format('DURATION', float_format(duration)),
135-
unquoted_format('PLANNED-DURATION', float_format(planned_duration)),
134+
unquoted_format('DURATION', decimal_format(duration)),
135+
unquoted_format('PLANNED-DURATION', decimal_format(planned_duration)),
136136
client_attributes_format,
137137
interstitial_formats,
138138
unquoted_format('SCTE35-CMD', scte35_cmd),
@@ -147,7 +147,7 @@ def client_attributes_format
147147

148148
client_attributes.map do |attribute|
149149
value = attribute.last
150-
fmt = decimal?(value) ? float_format(value) : %("#{value}")
150+
fmt = decimal?(value) ? decimal_format(value) : %("#{value}")
151151
"#{attribute.first}=#{fmt}"
152152
end
153153
end
@@ -166,8 +166,8 @@ def decimal?(value)
166166
def interstitial_formats
167167
[quoted_format('X-ASSET-URI', asset_uri),
168168
quoted_format('X-ASSET-LIST', asset_list),
169-
unquoted_format('X-RESUME-OFFSET', float_format(resume_offset)),
170-
unquoted_format('X-PLAYOUT-LIMIT', float_format(playout_limit)),
169+
unquoted_format('X-RESUME-OFFSET', decimal_format(resume_offset)),
170+
unquoted_format('X-PLAYOUT-LIMIT', decimal_format(playout_limit)),
171171
quoted_format('X-RESTRICT', restrict),
172172
quoted_format('X-SNAP', snap),
173173
quoted_format('X-TIMELINE-OCCUPIES', timeline_occupies),

lib/m3u8/part_item.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def to_s
4545
private
4646

4747
def formatted_attributes
48-
[unquoted_format('DURATION', float_format(duration)),
48+
[unquoted_format('DURATION', decimal_format(duration)),
4949
quoted_format('URI', uri),
5050
independent_format,
5151
quoted_format('BYTERANGE', byterange),

lib/m3u8/segment_item.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def self.parse(text)
3333
# Render as an m3u8 EXTINF tag with segment URI.
3434
# @return [String]
3535
def to_s
36-
"#EXTINF:#{float_format(duration)},#{comment}#{byterange_format}" \
36+
"#EXTINF:#{decimal_format(duration)},#{comment}#{byterange_format}" \
3737
"\n#{date_format}#{segment}"
3838
end
3939

0 commit comments

Comments
 (0)