Class: Chordpro::Song

Inherits:
Object
  • Object
show all
Defined in:
lib/chordpro/song.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elements = []) ⇒ Song

Returns a new instance of Song.



5
6
7
8
# File 'lib/chordpro/song.rb', line 5

def initialize(elements = [])
  @elements = elements
  @metadata = Metadata.new(@elements)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/chordpro/song.rb', line 14

def method_missing(method, *args)
  if respond_to_missing?(method)
    [method]
  else
    super
  end
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



3
4
5
# File 'lib/chordpro/song.rb', line 3

def elements
  @elements
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3
4
5
# File 'lib/chordpro/song.rb', line 3

def 
  @metadata
end

Instance Method Details

#accept(visitor) ⇒ Object



10
11
12
# File 'lib/chordpro/song.rb', line 10

def accept(visitor)
  elements.map { |element| element.accept(visitor) }
end

#respond_to_missing?(method, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/chordpro/song.rb', line 22

def respond_to_missing?(method, include_all = false)
  super || !!Directive.find(method)&.meta
end