Class: CoercedPercent

Inherits:
Struct
  • Object
show all
Defined in:
lib/percentable/coerced_percent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#percentObject

Returns the value of attribute percent

Returns:

  • (Object)

    the current value of percent



1
2
3
# File 'lib/percentable/coerced_percent.rb', line 1

def percent
  @percent
end

Instance Method Details

#*(other) ⇒ Object



10
11
12
# File 'lib/percentable/coerced_percent.rb', line 10

def * other
  other * percent.to_f
end

#+(other) ⇒ Object



2
3
4
# File 'lib/percentable/coerced_percent.rb', line 2

def + other
  other + self * other
end

#-(other) ⇒ Object



6
7
8
# File 'lib/percentable/coerced_percent.rb', line 6

def - other
  other - self * other
end

#/(other) ⇒ Object



14
15
16
# File 'lib/percentable/coerced_percent.rb', line 14

def / other
  other / percent.to_f
end