lib/nyaplot/data.rb in nyaplot-0.1.1 vs lib/nyaplot/data.rb in nyaplot-0.1.2
- old
+ new
@@ -168,42 +168,33 @@
def column_labels
@rows[0].keys
end
- def method_missing(name, *args)
+ def method_missing(name, *args, &block)
if md = name.match(/(.+)\=/)
self.insert_column(name[/(.+)\=/].delete("="), args[0])
return
- else
+ elsif column_labels.include?(name)
return self.column(name)
+ else
+ super(name, *args, &block)
end
end
end
class Series
include Enumerable
+ def each(&block)
+ @arr.each(&block)
+ end
def initialize(label, arr)
@arr = arr
@label = label
end
- def each
- @arr.each do |item|
- yield item
- end
- end
-
- def min
- @arr.min
- end
-
- def max
- @arr.max
- end
-
def to_html(threshold=15)
html = '<table><tr><th>' + label.to_s + '</th></tr>>'
@arr.each_with_index do |el,i|
next if threshold < i && i < @arr.length-1
content = i == threshold ? '...' : el.to_s
@@ -221,7 +212,21 @@
end
def label
@label
end
+
+ def method_missing(meth, *args, &block)
+ if @arr.respond_to?(meth)
+ @arr.send(meth, *args, &block)
+ else
+ super(meth, *args, &block)
+ end
+ end
+
+ def respond_to?(meth)
+ return true if @arr.respond_to?(meth)
+ super(meth)
+ end
+
end
end