Class: JIJI::BaseOut

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/jiji/output.rb

Overview

出力先の基底クラス

Direct Known Subclasses

EventOut, GraphOut

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, name, options) ⇒ BaseOut

コンストラクタ



100
101
102
103
104
# File 'lib/jiji/output.rb', line 100

def initialize( dir, name, options )
  @dir = dir
  @dao = JIJI::Dao::TimedDataDao.new( dir, aggregators )
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

補足情報



130
131
132
# File 'lib/jiji/output.rb', line 130

def options
  @options
end

#timeObject

現在時刻



132
133
134
# File 'lib/jiji/output.rb', line 132

def time
  @time
end

Instance Method Details

#each(scale = :raw, start_date = nil, end_date = nil, &block) ⇒ Object

データを読み込む



107
108
109
110
111
# File 'lib/jiji/output.rb', line 107

def each( scale=:raw, start_date=nil, end_date=nil, &block )
  @dao.each_data( scale, start_date, end_date ) { |row, time|
    yield row
  }
end

#saveObject

設定値をファイルに出力



123
124
125
126
127
# File 'lib/jiji/output.rb', line 123

def save
  FileLock.new("#{@dir}/meta.yaml" ).writelock { |f|
    f.write( YAML.dump(@options) )
  }
end

#set_properties(props) ⇒ Object

プロパティを設定する。

props

プロパティ



115
116
117
118
119
120
# File 'lib/jiji/output.rb', line 115

def set_properties( props )
  props.each_pair {|k,v|
    @options[k.to_sym] = v
  }
  save
end