Class: Height::Parsers::Metric

Inherits:
Base
  • Object
show all
Defined in:
lib/height/parsers/metric.rb

Instance Attribute Summary

Attributes inherited from Base

#input, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parsed?

Constructor Details

This class inherits a constructor from Height::Parsers::Base

Class Method Details

.parse(input) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/height/parsers/metric.rb', line 25

def self.parse(input)
  if input.is_a? Integer
    parse_integer(input)
  elsif input.is_a? Float
    parse_float(input)
  elsif input.is_a? String
    parse_string(input)
  end
end

Instance Method Details

#centimetersObject



9
10
11
# File 'lib/height/parsers/metric.rb', line 9

def centimeters
  millimeters.to_centimeters
end

#feetObject



21
22
23
# File 'lib/height/parsers/metric.rb', line 21

def feet
  inches.to_feet
end

#inchesObject



17
18
19
# File 'lib/height/parsers/metric.rb', line 17

def inches
  millimeters.to_inches
end

#metersObject



13
14
15
# File 'lib/height/parsers/metric.rb', line 13

def meters
  millimeters.to_meters
end

#millimetersObject



5
6
7
# File 'lib/height/parsers/metric.rb', line 5

def millimeters
  Height::Units::Millimeters.new(value)
end