Class: Reputation::Functions::Step

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/reputation/functions/step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin

#google_chart, #google_chart_url

Constructor Details

#initialize(args = {}) ⇒ Step

Returns a new instance of Step



9
10
11
12
13
14
15
16
17
18
# File 'lib/reputation/functions/step.rb', line 9

def initialize(args = {})
  constants = {
    :a => -1,  # lower asymptote
    :k => 1,   # upper asymptote
    :c => 0.5  # point of switch
  }.merge( args )
  @c = constants[:c]
  @k = constants[:k]
  @a = constants[:a]
end

Instance Attribute Details

#aObject

Returns the value of attribute a



7
8
9
# File 'lib/reputation/functions/step.rb', line 7

def a
  @a
end

#cObject

Returns the value of attribute c



7
8
9
# File 'lib/reputation/functions/step.rb', line 7

def c
  @c
end

#kObject

Returns the value of attribute k



7
8
9
# File 'lib/reputation/functions/step.rb', line 7

def k
  @k
end

Instance Method Details

#f(x) ⇒ Object



20
21
22
# File 'lib/reputation/functions/step.rb', line 20

def f(x)
  limit( x.to_f >= c.to_f ? k : a )
end