Class: CSSensible::EmValue
- Inherits:
-
Numeric
- Object
- Numeric
- CSSensible::EmValue
- Includes:
- Comparable
- Defined in:
- lib/cssensible/em_value.rb
Constant Summary collapse
- MAX_DECIMAL_PLACES =
The maximum number of decimal places allowed in an em-value.
3
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value) ⇒ EmValue
constructor
Returns a new em-value based on the value passed to new.
- #to_f ⇒ Object
- #to_s ⇒ Object
-
#usable? ⇒ Boolean
:call-seq: usable? -> true or false.
Constructor Details
#initialize(value) ⇒ EmValue
Returns a new em-value based on the value passed to new.
18 19 20 |
# File 'lib/cssensible/em_value.rb', line 18 def initialize(value) @value = value.to_f end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/cssensible/em_value.rb', line 11 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
13 14 15 |
# File 'lib/cssensible/em_value.rb', line 13 def <=>(other) @value <=> other.value end |
#to_f ⇒ Object
32 33 34 |
# File 'lib/cssensible/em_value.rb', line 32 def to_f @value.to_f end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/cssensible/em_value.rb', line 36 def to_s @value.to_s end |
#usable? ⇒ Boolean
:call-seq:
usable? -> true or false
Returns true if the em-value has no more decimal places than specified in MAX_DECIMAL_PLACES.
27 28 29 30 |
# File 'lib/cssensible/em_value.rb', line 27 def usable? # shift decimal point and check if no decimal places remain @value.shift_decimal_point(MAX_DECIMAL_PLACES).decimal_places.zero? end |