Class: MPD::Controller::Stickers::Element
- Inherits:
-
Object
- Object
- MPD::Controller::Stickers::Element
- Includes:
- Enumerable
- Defined in:
- lib/mpd/controller/stickers.rb
Instance Attribute Summary collapse
-
#stickers ⇒ Object
readonly
Returns the value of attribute stickers.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #delete(name) ⇒ Object
- #each ⇒ Object
-
#initialize(stickers, type, uri) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(stickers, type, uri) ⇒ Element
Returns a new instance of Element.
47 48 49 50 51 |
# File 'lib/mpd/controller/stickers.rb', line 47 def initialize (stickers, type, uri) @stickers = stickers @type = type @uri = uri end |
Instance Attribute Details
#stickers ⇒ Object (readonly)
Returns the value of attribute stickers.
45 46 47 |
# File 'lib/mpd/controller/stickers.rb', line 45 def stickers @stickers end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
45 46 47 |
# File 'lib/mpd/controller/stickers.rb', line 45 def type @type end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
45 46 47 |
# File 'lib/mpd/controller/stickers.rb', line 45 def uri @uri end |
Instance Method Details
#[](name) ⇒ Object
53 54 55 |
# File 'lib/mpd/controller/stickers.rb', line 53 def [] (name) find { |s| s.name == name.to_s } end |
#delete(name) ⇒ Object
57 58 59 |
# File 'lib/mpd/controller/stickers.rb', line 57 def delete (name) self[name].delete! rescue nil end |
#each ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mpd/controller/stickers.rb', line 61 def each return to_enum unless block_given? @stickers.controller.do_and_raise_if_needed(:sticker, :list, type, uri).each {|_, sticker| name, value = sticker.split '=', 2 yield Sticker.new(self, name) } self end |