Class: Clef::Layout::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/layout/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, moment:, staff_id: nil, measure_number: nil, payload: {}) ⇒ Item

Returns a new instance of Item.

Parameters:

  • type (Symbol)
  • moment (Clef::Ir::Moment)
  • staff_id (Symbol, String, nil) (defaults to: nil)
  • measure_number (Integer, nil) (defaults to: nil)
  • payload (Hash) (defaults to: {})

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/clef/layout/item.rb', line 13

def initialize(type:, moment:, staff_id: nil, measure_number: nil, payload: {})
  raise ArgumentError, "type must be a Symbol" unless type.is_a?(Symbol)
  raise ArgumentError, "moment must be a Clef::Ir::Moment" unless moment.is_a?(Clef::Ir::Moment)
  raise ArgumentError, "payload must be a Hash" unless payload.is_a?(Hash)

  @type = type
  @moment = moment
  @staff_id = staff_id
  @measure_number = measure_number
  @payload = payload.dup
end

Instance Attribute Details

#measure_numberObject (readonly)

Returns the value of attribute measure_number.



6
7
8
# File 'lib/clef/layout/item.rb', line 6

def measure_number
  @measure_number
end

#momentObject (readonly)

Returns the value of attribute moment.



6
7
8
# File 'lib/clef/layout/item.rb', line 6

def moment
  @moment
end

#payloadObject (readonly)

Returns the value of attribute payload.



6
7
8
# File 'lib/clef/layout/item.rb', line 6

def payload
  @payload
end

#staff_idObject (readonly)

Returns the value of attribute staff_id.



6
7
8
# File 'lib/clef/layout/item.rb', line 6

def staff_id
  @staff_id
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/clef/layout/item.rb', line 6

def type
  @type
end