Class: Squid::AxisLabel

Inherits:
Object
  • Object
show all
Defined in:
lib/squid/axis_label.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, y:, align:, width:) ⇒ AxisLabel

Returns a new instance of AxisLabel.



11
12
13
# File 'lib/squid/axis_label.rb', line 11

def initialize(label:, y:, align:, width:)
  @label, @y, @align, @width = label, y, align, width
end

Instance Attribute Details

#alignObject (readonly)

Returns the value of attribute align.



9
10
11
# File 'lib/squid/axis_label.rb', line 9

def align
  @align
end

#labelObject (readonly)

Returns the value of attribute label.



9
10
11
# File 'lib/squid/axis_label.rb', line 9

def label
  @label
end

#widthObject (readonly)

Returns the value of attribute width.



9
10
11
# File 'lib/squid/axis_label.rb', line 9

def width
  @width
end

#yObject (readonly)

Returns the value of attribute y.



9
10
11
# File 'lib/squid/axis_label.rb', line 9

def y
  @y
end

Class Method Details

.for(axis, height:, align:) ⇒ Object



3
4
5
6
7
# File 'lib/squid/axis_label.rb', line 3

def self.for(axis, height:, align:)
  height.step(0, -height/(axis.labels.size-1).to_f).map.with_index do |y, i|
    new y: y, label: axis.labels[i], align: align, width: axis.width
  end
end