Class: PopCap::Formatters::BitRate
- Defined in:
- lib/pop_cap/formatters/bit_rate.rb
Overview
Public: This is a formatter for the bit_rate tag. It is used to make the bitrate human readable.
bitrate - The bitrate can be sent as a string or integer.
Instance Attribute Summary
Attributes inherited from Formatter
Instance Method Summary collapse
-
#format ⇒ Object
Public: This method returns a bitrate represented in kilobytes.
Methods inherited from Formatter
format, #initialize, subclasses, subclasses_demodulized
Constructor Details
This class inherits a constructor from PopCap::Formatters::Formatter
Instance Method Details
#format ⇒ Object
Public: This method returns a bitrate represented in kilobytes.
It returns nil for anything that is not a number greater than zero.
Examples
br = BitRate.new(128456)
br.format
# => '128 kb/s'
21 22 23 24 |
# File 'lib/pop_cap/formatters/bit_rate.rb', line 21 def format return unless @value.to_i > 0 @value.to_s[0..-4] + ' kb/s' end |