Class: Clef::Engraving::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/engraving/style.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page_size: "A4", margin: 36, staff_size: 20, staff_space: 10, min_note_spacing: nil, line_width: 820, system_gap: 72, staff_gap: 90, measure_padding: 14, notehead_width: 7, beam_thickness: nil) ⇒ Style

Returns a new instance of Style.

Parameters:

  • page_size (String, Array) (defaults to: "A4")
  • margin (Numeric) (defaults to: 36)
  • staff_size (Numeric) (defaults to: 20)
  • staff_space (Numeric) (defaults to: 10)
  • min_note_spacing (Numeric) (defaults to: nil)
  • line_width (Numeric) (defaults to: 820)
  • system_gap (Numeric) (defaults to: 72)
  • staff_gap (Numeric) (defaults to: 90)
  • measure_padding (Numeric) (defaults to: 14)
  • notehead_width (Numeric) (defaults to: 7)
  • beam_thickness (Numeric) (defaults to: nil)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/clef/engraving/style.rb', line 21

def initialize(page_size: "A4", margin: 36, staff_size: 20, staff_space: 10, min_note_spacing: nil,
  line_width: 820, system_gap: 72, staff_gap: 90, measure_padding: 14,
  notehead_width: 7, beam_thickness: nil)
  min_note_spacing ||= Rules::MIN_NOTE_SPACING * staff_space
  beam_thickness ||= Rules::BEAM_THICKNESS * staff_space

  validate_positive!(
    margin: margin,
    staff_size: staff_size,
    staff_space: staff_space,
    min_note_spacing: min_note_spacing,
    line_width: line_width,
    system_gap: system_gap,
    staff_gap: staff_gap,
    measure_padding: measure_padding,
    notehead_width: notehead_width,
    beam_thickness: beam_thickness
  )

  @page_size = page_size
  @margin = margin
  @staff_size = staff_size
  @staff_space = staff_space
  @min_note_spacing = min_note_spacing
  @line_width = line_width
  @system_gap = system_gap
  @staff_gap = staff_gap
  @measure_padding = measure_padding
  @notehead_width = notehead_width
  @beam_thickness = beam_thickness
end

Instance Attribute Details

#beam_thicknessObject (readonly)

Returns the value of attribute beam_thickness.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def beam_thickness
  @beam_thickness
end

#line_widthObject (readonly)

Returns the value of attribute line_width.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def line_width
  @line_width
end

#marginObject (readonly)

Returns the value of attribute margin.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def margin
  @margin
end

#measure_paddingObject (readonly)

Returns the value of attribute measure_padding.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def measure_padding
  @measure_padding
end

#min_note_spacingObject (readonly)

Returns the value of attribute min_note_spacing.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def min_note_spacing
  @min_note_spacing
end

#notehead_widthObject (readonly)

Returns the value of attribute notehead_width.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def notehead_width
  @notehead_width
end

#page_sizeObject (readonly)

Returns the value of attribute page_size.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def page_size
  @page_size
end

#staff_gapObject (readonly)

Returns the value of attribute staff_gap.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def staff_gap
  @staff_gap
end

#staff_sizeObject (readonly)

Returns the value of attribute staff_size.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def staff_size
  @staff_size
end

#staff_spaceObject (readonly)

Returns the value of attribute staff_space.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def staff_space
  @staff_space
end

#system_gapObject (readonly)

Returns the value of attribute system_gap.



6
7
8
# File 'lib/clef/engraving/style.rb', line 6

def system_gap
  @system_gap
end

Class Method Details

.defaultStyle

Returns:



54
55
56
# File 'lib/clef/engraving/style.rb', line 54

def self.default
  new
end