Class: Triangular::Units

Inherits:
Object
  • Object
show all
Defined in:
lib/triangular/units.rb

Constant Summary collapse

UNITS =
{
  :inches      => {:name => 'inches', :svg_name => 'in', :stroke_width => 0.005},
  :centimeters => {:name => 'centimeters', :svg_name => 'cm', :stroke_width => 0.01},
  :millimeters => {:name => 'millimeters', :svg_name => 'mm', :stroke_width => 0.1},
  :none        => {:name => 'none', :svg_name => '', :stroke_width => 0.1}
}

Class Method Summary collapse

Class Method Details

.get_property(unit, name) ⇒ Object



13
14
15
16
# File 'lib/triangular/units.rb', line 13

def self.get_property(unit, name)
  raise "Unknown unit: #{unit}" unless UNITS.has_key?(unit)
  UNITS[unit][name]
end

.name(unit) ⇒ Object



18
19
20
# File 'lib/triangular/units.rb', line 18

def self.name(unit)
  self.get_property(unit, :name)
end

.stroke_width(unit) ⇒ Object



26
27
28
# File 'lib/triangular/units.rb', line 26

def self.stroke_width(unit)
  self.get_property(unit, :stroke_width)
end

.svg_name(unit) ⇒ Object



22
23
24
# File 'lib/triangular/units.rb', line 22

def self.svg_name(unit)
  self.get_property(unit, :svg_name)
end