Class: IRealB::Parser::Tune

Inherits:
Object
  • Object
show all
Defined in:
lib/irealb/parser/tune.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Tune

Returns a new instance of Tune.



10
11
12
13
14
15
16
# File 'lib/irealb/parser/tune.rb', line 10

def initialize(attributes = {})
  self.chord_groupings = []

  attributes.each do |key, value|
    self.send("#{key}=", value) if respond_to?(key)
  end
end

Instance Attribute Details

#chord_groupingsObject

Returns the value of attribute chord_groupings.



8
9
10
# File 'lib/irealb/parser/tune.rb', line 8

def chord_groupings
  @chord_groupings
end

#composerObject

Returns the value of attribute composer.



5
6
7
# File 'lib/irealb/parser/tune.rb', line 5

def composer
  @composer
end

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/irealb/parser/tune.rb', line 7

def key
  @key
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/irealb/parser/tune.rb', line 4

def name
  @name
end

#styleObject

Returns the value of attribute style.



6
7
8
# File 'lib/irealb/parser/tune.rb', line 6

def style
  @style
end

Instance Method Details

#as_json(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/irealb/parser/tune.rb', line 18

def as_json(options = {})
  {
    :name => name,
    :composer => composer,
    :style => style,
    :key => key,
    :changes => chord_groupings.as_json
  }.reject {|k,v| v.nil? }
end