Class: WahlrechtDe::Datapoint
- Inherits:
-
Object
- Object
- WahlrechtDe::Datapoint
- Includes:
- Comparable
- Defined in:
- lib/datapoint.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #format_data(data) ⇒ Object
-
#initialize(data) ⇒ Datapoint
constructor
A new instance of Datapoint.
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ Datapoint
Returns a new instance of Datapoint.
6 7 8 9 |
# File 'lib/datapoint.rb', line 6 def initialize data format_data data @content = data end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/datapoint.rb', line 4 def content @content end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 |
# File 'lib/datapoint.rb', line 17 def <=> other Float(self.content) <=> Float(other.content) end |
#format_data(data) ⇒ Object
11 12 13 14 15 |
# File 'lib/datapoint.rb', line 11 def format_data data data.sub! ",", "." data.chomp! " %" data.chomp! ".0" end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/datapoint.rb', line 21 def to_s "#{@content}" end |