Class: Radiodan::Track
- Inherits:
-
Object
- Object
- Radiodan::Track
- Extended by:
- Forwardable
- Defined in:
- lib/radiodan/track.rb
Defined Under Namespace
Classes: NoFileError
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql? ⇒ Object
-
#initialize(attributes = {}) ⇒ Track
constructor
A new instance of Track.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Track
Returns a new instance of Track.
14 15 16 17 18 19 |
# File 'lib/radiodan/track.rb', line 14 def initialize(attributes={}) @attributes = HashWithIndifferentAccess.new(attributes) unless @attributes.has_key?(:file) raise NoFileError, 'No file given for track' end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/radiodan/track.rb', line 25 def method_missing(method, *args, &block) if @attributes.include?(method) @attributes[method] else super end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/radiodan/track.rb', line 8 def attributes @attributes end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/radiodan/track.rb', line 21 def ==(other) self[:file] == other[:file] end |
#eql? ⇒ Object
12 |
# File 'lib/radiodan/track.rb', line 12 alias_method :eql?, :== |
#respond_to?(method) ⇒ Boolean
33 34 35 36 37 38 39 |
# File 'lib/radiodan/track.rb', line 33 def respond_to?(method) if @attributes.include?(method) true else super end end |