Module: EideticRML::Support
- Included in:
- EideticRML::Styles::Style, Widgets::Widget
- Defined in:
- lib/erml_support.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse_measurement(value, units = :pt) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/erml_support.rb', line 16 def parse_measurement(value, units=:pt) value, units = if value =~ /([+-]?\d+(\.\d+)?)([a-z]+)/ [$1.to_f, ($3 || :pt).to_sym] else [value.to_f, units.to_sym] end units = :pt unless EideticPDF::UNIT_CONVERSION[units] [value, units] end |
.parse_measurement_pts(value, units = :pt) ⇒ Object
26 27 28 29 |
# File 'lib/erml_support.rb', line 26 def parse_measurement_pts(value, units=:pt) v, u = parse_measurement(value, units) v * EideticPDF::UNIT_CONVERSION[u] end |
Instance Method Details
#from_units(units, measurement) ⇒ Object
31 32 33 |
# File 'lib/erml_support.rb', line 31 def from_units(units, measurement) measurement.to_f * EideticPDF::UNIT_CONVERSION[units] end |
#to_units(units, measurement) ⇒ Object
35 36 37 |
# File 'lib/erml_support.rb', line 35 def to_units(units, measurement) measurement.to_f / EideticPDF::UNIT_CONVERSION[units] end |