Class: Nyaplot::Series
- Inherits:
-
Object
- Object
- Nyaplot::Series
- Includes:
- Enumerable
- Defined in:
- lib/nyaplot/data.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(label, arr) ⇒ Series
constructor
A new instance of Series.
- #label ⇒ Object
- #max ⇒ Object
- #min ⇒ Object
- #to_a ⇒ Object
- #to_html(threshold = 15) ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(label, arr) ⇒ Series
Returns a new instance of Series.
186 187 188 189 |
# File 'lib/nyaplot/data.rb', line 186 def initialize(label, arr) @arr = arr @label = label end |
Instance Method Details
#each ⇒ Object
191 192 193 194 195 |
# File 'lib/nyaplot/data.rb', line 191 def each @arr.each do |item| yield item end end |
#label ⇒ Object
223 224 225 |
# File 'lib/nyaplot/data.rb', line 223 def label @label end |
#max ⇒ Object
201 202 203 |
# File 'lib/nyaplot/data.rb', line 201 def max @arr.max end |
#min ⇒ Object
197 198 199 |
# File 'lib/nyaplot/data.rb', line 197 def min @arr.min end |
#to_a ⇒ Object
219 220 221 |
# File 'lib/nyaplot/data.rb', line 219 def to_a @arr end |
#to_html(threshold = 15) ⇒ Object
205 206 207 208 209 210 211 212 213 |
# File 'lib/nyaplot/data.rb', line 205 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 html.concat('<tr><td>' + content + '</td></tr>') end html += '</table>' end |
#to_json(*args) ⇒ Object
215 216 217 |
# File 'lib/nyaplot/data.rb', line 215 def to_json(*args) @arr.to_json end |