Class: Moc::Controller::Status::Live::Song
- Inherits:
-
Object
- Object
- Moc::Controller::Status::Live::Song
- Defined in:
- lib/moc/controller/status.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
- #average_bitrate ⇒ Object
- #bitrate ⇒ Object
- #channels ⇒ Object
- #duration ⇒ Object
- #file ⇒ Object
-
#initialize(controller) ⇒ Song
constructor
A new instance of Song.
- #inspect ⇒ Object
- #position ⇒ Object
- #rate ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(controller) ⇒ Song
Returns a new instance of Song.
18 19 20 |
# File 'lib/moc/controller/status.rb', line 18 def initialize (controller) @controller = controller end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
16 17 18 |
# File 'lib/moc/controller/status.rb', line 16 def controller @controller end |
Instance Method Details
#average_bitrate ⇒ Object
37 38 39 40 |
# File 'lib/moc/controller/status.rb', line 37 def average_bitrate controller.send_command :get_avg_bitrate controller.get_integer.to_i end |
#bitrate ⇒ Object
32 33 34 35 |
# File 'lib/moc/controller/status.rb', line 32 def bitrate controller.send_command :get_bitrate controller.get_integer.to_i end |
#channels ⇒ Object
22 23 24 25 |
# File 'lib/moc/controller/status.rb', line 22 def channels controller.send_command :get_channels controller.get_integer.to_i end |
#duration ⇒ Object
75 76 77 |
# File 'lib/moc/controller/status.rb', line 75 def duration .time if end |
#file ⇒ Object
47 48 49 50 |
# File 'lib/moc/controller/status.rb', line 47 def file controller.send_command :get_sname controller.get_string.to_s end |
#inspect ⇒ Object
79 80 81 |
# File 'lib/moc/controller/status.rb', line 79 def inspect "#<#{self.class.name}: track=#{track} title=#{title.inspect} artist=#{artist.inspect} album=#{album.inspect} channels=#{channels} bitrate=#{bitrate}(#{average_bitrate}) position=#{position}/#{duration || ??}>" end |
#position ⇒ Object
42 43 44 45 |
# File 'lib/moc/controller/status.rb', line 42 def position controller.send_command :get_ctime controller.get_integer.to_i end |
#rate ⇒ Object
27 28 29 30 |
# File 'lib/moc/controller/status.rb', line 27 def rate controller.send_command :get_rate controller.get_integer.to_i end |
#tags ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/moc/controller/status.rb', line 52 def path = file if path.start_with?('http://') || path.start_with?('ftp://') controller.send_command :get_tags controller. else controller.send_command :get_file_tags controller.send_string path controller.send_integer 0x01 | 0x02 controller.wait_for(:file_tags). end end |