Class: JIJI::Output
Overview
データの出力先
Instance Attribute Summary collapse
-
#scales ⇒ Object
スケール.
-
#time ⇒ Object
現在時刻.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
出力先を列挙する.
-
#get(name, type = :graph, options = {}) ⇒ Object
名前に対応する出力先を得る。 対応する出力先がなければ新規に作成。.
-
#initialize(agent_name, dir, scales = []) ⇒ Output
constructor
A new instance of Output.
Constructor Details
#initialize(agent_name, dir, scales = []) ⇒ Output
Returns a new instance of Output.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jiji/output.rb', line 16 def initialize( agent_name, dir, scales=[] ) @dir = "#{dir}/#{JIJI::Util.encode(agent_name).gsub(/\//, "_")}" # 「ベースディレクトリ/エージェント名/出力名」に保存する。 FileUtils.mkdir_p @dir @outs = {} @scales = scales # 既存データの読み込み DirLock.new( @dir ).writelock { Dir.glob( "#{@dir}/*" ) {|d| next unless File.directory? d next unless File.exist? "#{d}/meta.yaml" props = YAML.load_file "#{d}/meta.yaml" @outs[props[:name]] = create_output( d, props[:name], props[:type].to_sym, props ) } } end |
Instance Attribute Details
#scales ⇒ Object
スケール
79 80 81 |
# File 'lib/jiji/output.rb', line 79 def scales @scales end |
#time ⇒ Object
現在時刻
77 78 79 |
# File 'lib/jiji/output.rb', line 77 def time @time end |
Instance Method Details
#each(&block) ⇒ Object
出力先を列挙する
65 66 67 |
# File 'lib/jiji/output.rb', line 65 def each( &block ) @outs.each( &block ) end |
#get(name, type = :graph, options = {}) ⇒ Object
名前に対応する出力先を得る。対応する出力先がなければ新規に作成。
- name
-
名前(UIでの表示名)
- type
-
種別。:event,:graphのいずれかが指定可能
- option
-
補足情報。以下が指定可能
-*グラフの場合* –[:column_count] .. グラフのカラム数を整数値で指定する。(*必須*) –「:graph_type」 .. グラフの種類を指定する。以下の値が指定可能。—“rate” .. レート情報に重ねて表示(移動平均線やボリンジャーバンド向け)。グラフは、ローソク足描画領域に描画される。—“zero_base” .. 0を中心線とした線グラフ(RCIやMACD向け)。グラフは、グラフ描画領域に描画される。—“line” .. 線グラフとして描画する。(デフォルト)。グラフは、グラフ描画領域に描画される。–「:colors」 .. グラフの色を「#FFFFFF」形式の文字列の配列で指定する。指定を省略した場合「0x557777」で描画される。
- return
-
出力先
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/jiji/output.rb', line 49 def get( name, type=:graph, ={} ) raise "illegal Name. name=#{name}" if name =~ /[\x00-\x1F\x7F\\\/\r\n\t]/ return @outs[name] if @outs.key? name DirLock.new( @dir ).writelock { sub_dir = "#{@dir}/#{JIJI::Util.encode(name).gsub(/\//, "_")}" FileUtils.mkdir_p sub_dir [:type] = type.to_s [:name] = name @outs[name] = create_output( sub_dir, name, type, ) @outs[name].time = time @outs[name].save } @outs[name] end |