Class: Clef::Notation::Barline

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/notation/barline.rb

Constant Summary collapse

TYPES =
%i[single double final repeat_start repeat_end repeat_both].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :single) ⇒ Barline

Returns a new instance of Barline.

Parameters:

  • type (Symbol) (defaults to: :single)

Raises:

  • (ArgumentError)


11
12
13
14
15
# File 'lib/clef/notation/barline.rb', line 11

def initialize(type = :single)
  raise ArgumentError, "unsupported barline type" unless TYPES.include?(type)

  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/clef/notation/barline.rb', line 8

def type
  @type
end

Instance Method Details

#to_symbolString

Returns:

  • (String)


18
19
20
21
22
23
24
25
26
27
# File 'lib/clef/notation/barline.rb', line 18

def to_symbol
  {
    single: "|",
    double: "||",
    final: "|.",
    repeat_start: ".|:",
    repeat_end: ":|.",
    repeat_both: ":|.|:"
  }.fetch(type)
end