Class: WahlrechtDe::Datapoint

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/datapoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (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_sObject



21
22
23
# File 'lib/datapoint.rb', line 21

def to_s
	"#{@content}"
end