Class: JIJI::PeriodicallyValue

Inherits:
Object
  • Object
show all
Includes:
Util::Model
Defined in:
lib/jiji/models.rb

Overview

一定期間の値

始値、終値、高値、安値の四本値

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Model

#==, #===, #eql?, #hash

Constructor Details

#initialize(list = []) ⇒ PeriodicallyValue

コンストラクタ

list

初期データ



190
191
192
193
194
# File 'lib/jiji/models.rb', line 190

def initialize( list=[] )
  list.each { |item|
    self << item
  }
end

Instance Attribute Details

#endObject (readonly)

終値



217
218
219
# File 'lib/jiji/models.rb', line 217

def end
  @end
end

#maxObject (readonly)

高値



219
220
221
# File 'lib/jiji/models.rb', line 219

def max
  @max
end

#minObject (readonly)

安値



221
222
223
# File 'lib/jiji/models.rb', line 221

def min
  @min
end

#startObject (readonly)

始値



215
216
217
# File 'lib/jiji/models.rb', line 215

def start
  @start
end

Instance Method Details

#<<(value) ⇒ Object

値を追加し四本値を再計算します。

value



197
198
199
200
201
202
# File 'lib/jiji/models.rb', line 197

def <<( value )
  @start = value if @start == nil
  @end = value
  @max = value if @max == nil || value > @max
  @min = value if @min == nil || value < @min
end

#valuesObject

値を配列で取得する



204
205
206
# File 'lib/jiji/models.rb', line 204

def values #:nodoc:
  [@start, @end, @max, @min]
end

#values=(values) ⇒ Object

値を配列で設定する



208
209
210
211
212
213
# File 'lib/jiji/models.rb', line 208

def values=(values) #:nodoc:
  @start = values[0].to_f
  @end   = values[1].to_f
  @max   = values[2].to_f
  @min   = values[3].to_f
end