Class: Candelabra::EventCmd
- Inherits:
-
Object
- Object
- Candelabra::EventCmd
- Defined in:
- lib/candelabra/event_cmd.rb
Instance Attribute Summary collapse
-
#album ⇒ Object
readonly
Returns the value of attribute album.
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#coverArt ⇒ Object
readonly
Returns the value of attribute coverArt.
-
#stationName ⇒ Object
readonly
Returns the value of attribute stationName.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#art_work ⇒ Object
The 2011 release of pianobar supports album art.
-
#initialize(args) ⇒ EventCmd
constructor
Inigialize the Event Command with the given command Once we have the command we can preform different actions.
-
#parse(data) ⇒ Object
Parse out the data from stdin.
-
#run ⇒ Object
Run the command.
Methods included from Ubuntu
Methods included from OSX
Constructor Details
#initialize(args) ⇒ EventCmd
Inigialize the Event Command with the given command Once we have the command we can preform different actions
10 11 12 |
# File 'lib/candelabra/event_cmd.rb', line 10 def initialize(args) @command = args.shift end |
Instance Attribute Details
#album ⇒ Object (readonly)
Returns the value of attribute album.
6 7 8 |
# File 'lib/candelabra/event_cmd.rb', line 6 def album @album end |
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
6 7 8 |
# File 'lib/candelabra/event_cmd.rb', line 6 def artist @artist end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/candelabra/event_cmd.rb', line 6 def command @command end |
#coverArt ⇒ Object (readonly)
Returns the value of attribute coverArt.
6 7 8 |
# File 'lib/candelabra/event_cmd.rb', line 6 def coverArt @coverArt end |
#stationName ⇒ Object (readonly)
Returns the value of attribute stationName.
6 7 8 |
# File 'lib/candelabra/event_cmd.rb', line 6 def stationName @stationName end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/candelabra/event_cmd.rb', line 6 def title @title end |
Instance Method Details
#art_work ⇒ Object
The 2011 release of pianobar supports album art. If wen have album are the it will be displayed in the notification
Returns nil or the path of the file
44 45 46 47 48 49 50 |
# File 'lib/candelabra/event_cmd.rb', line 44 def art_work if coverArt Dir.glob('*.jpg').each { |imge| File.delete(imge) } File.open( 'img.jpg', 'wb' ) { |f| f.write Net::HTTP.get( URI.parse( coverArt ) ) } Dir.glob('*.jpg').first end end |
#parse(data) ⇒ Object
Parse out the data from stdin. This will set instance vars that are named the same as the input from pianobar
Retruns nothing
32 33 34 35 36 37 38 |
# File 'lib/candelabra/event_cmd.rb', line 32 def parse(data) data.each do |key_value| key, value = key_value.chomp.split('=') key = key instance_variable_set( "@#{key}".to_sym, value ) end end |
#run ⇒ Object
Run the command. Part of running the command
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/candelabra/event_cmd.rb', line 15 def run parse( $stdin ) case command when 'songstart' notify Remote.flush when 'userlogin' unless @pRet.to_i == 1 `ps a | grep 'candelabra install' | cut -c1-5`.split("\n").each{|id| `kill #{id}` unless Process.pid == id.to_i } end end end |