Class: RCharts::Percentage

Inherits:
Object
  • Object
show all
Defined in:
lib/rcharts/percentage.rb

Overview

:nodoc:

Constant Summary collapse

MAX =
new(100.0)
MIN =
new(0.0)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Percentage

Returns a new instance of Percentage.



15
16
17
# File 'lib/rcharts/percentage.rb', line 15

def initialize(value)
  @value = value.to_f
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/rcharts/percentage.rb', line 5

def value
  @value
end

Class Method Details

.unwrap(value) ⇒ Object



11
12
13
# File 'lib/rcharts/percentage.rb', line 11

def self.unwrap(value)
  value.is_a?(Percentage) ? value.value : value
end

.wrap(value) ⇒ Object



7
8
9
# File 'lib/rcharts/percentage.rb', line 7

def self.wrap(value)
  value.is_a?(Percentage) ? value : new(value)
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/rcharts/percentage.rb', line 22

def ==(other)
  value == self.class.unwrap(other)
end

#to_sObject



32
33
34
# File 'lib/rcharts/percentage.rb', line 32

def to_s
  "#{value}%"
end