Class: Numo::Gnuplot::PlotItem
- Inherits:
-
Object
- Object
- Numo::Gnuplot::PlotItem
- Defined in:
- lib/numo/gnuplot.rb
Direct Known Subclasses
Class Method Summary collapse
-
.is_data(a) ⇒ Object
:nodoc: all.
Instance Method Summary collapse
- #<<(item) ⇒ Object
- #cmd_str ⇒ Object
- #data_str ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(*items) ⇒ PlotItem
constructor
A new instance of PlotItem.
- #parse_data(data) ⇒ Object
- #parse_items ⇒ Object
Constructor Details
#initialize(*items) ⇒ PlotItem
Returns a new instance of PlotItem.
427 428 429 |
# File 'lib/numo/gnuplot.rb', line 427 def initialize(*items) @items = items end |
Class Method Details
.is_data(a) ⇒ Object
:nodoc: all
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/numo/gnuplot.rb', line 408 def self.is_data(a) if a.kind_of? Array if a.last.kind_of?(Hash) return false else t = a.first.class t = Numeric if t < Numeric return a.all?{|e| e.kind_of?(t)} end elsif defined?(Numo::NArray) return true if a.kind_of?(Numo::NArray) elsif defined?(::NArray) return true if a.kind_of?(::NArray) elsif defined?(::NMatrix) return true if a.kind_of?(::NMatix) end false end |
Instance Method Details
#<<(item) ⇒ Object
431 432 433 |
# File 'lib/numo/gnuplot.rb', line 431 def <<(item) @items << item end |
#cmd_str ⇒ Object
471 472 473 474 475 476 477 478 |
# File 'lib/numo/gnuplot.rb', line 471 def cmd_str parse_items if @function "%s %s" % [@function, OptsToS.new(*)] else "%s %s" % [@data.cmd_str, OptsToS.new(*)] end end |
#data_str ⇒ Object
480 481 482 483 484 485 486 487 |
# File 'lib/numo/gnuplot.rb', line 480 def data_str parse_items if @function nil else @data.data_str end end |
#empty? ⇒ Boolean
435 436 437 |
# File 'lib/numo/gnuplot.rb', line 435 def empty? @items.empty? end |
#parse_data(data) ⇒ Object
467 468 469 |
# File 'lib/numo/gnuplot.rb', line 467 def parse_data(data) PlotData.new(*data) end |
#parse_items ⇒ Object
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/numo/gnuplot.rb', line 439 def parse_items if ! if @items.empty? return elsif @items.first.kind_of? String @function = @items.first = @items[1..-1] if (o=@items.last).kind_of? Hash if o.any?{|k,v| /^#{k}/ =~ "using"} # @function is data file @function = "'#{@function}'" end end else data = [] = [] @items.each do |x| if PlotItem.is_data(x) data << x else << x end end @data = parse_data(data) end end end |