Class: DataSeries
- Inherits:
-
Object
- Object
- DataSeries
- Defined in:
- lib/gnuplotr.rb
Instance Method Summary collapse
- #<<(ary) ⇒ Object
- #close ⇒ Object
-
#initialize(name) ⇒ DataSeries
constructor
A new instance of DataSeries.
Constructor Details
#initialize(name) ⇒ DataSeries
Returns a new instance of DataSeries.
10 11 12 13 14 15 16 17 |
# File 'lib/gnuplotr.rb', line 10 def initialize(name) raise ArgumentError, "name must be a Symbol" unless name.kind_of? Symbol @name = name @width = nil @length = 0 @handle = File.open("#{@name.to_s}.dat", "w") @handle.puts "\# #{@name} datafile generated on #{Time.now} by GNUPlotr" end |
Instance Method Details
#<<(ary) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/gnuplotr.rb', line 19 def <<(ary) @width = ary.size unless @width raise ArgumentError, "record size mismatch (not #{@width})" unless ary.size == @width @handle.puts(ary * "\t") @length += 1 end |
#close ⇒ Object
26 27 28 |
# File 'lib/gnuplotr.rb', line 26 def close @handle.close end |