Class: Nyaplot::Color
- Inherits:
-
Object
- Object
- Nyaplot::Color
- Defined in:
- lib/nyaplot/color.rb
Overview
The html interface to access Colorset
Instance Method Summary collapse
-
#initialize(arr) ⇒ Color
constructor
A new instance of Color.
- #to_a ⇒ Object
-
#to_html ⇒ String
display colorset on IRuby notebook as a html table.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(arr) ⇒ Color
Returns a new instance of Color.
54 55 56 |
# File 'lib/nyaplot/color.rb', line 54 def initialize(arr) @source = arr end |
Instance Method Details
#to_a ⇒ Object
58 59 60 |
# File 'lib/nyaplot/color.rb', line 58 def to_a @source end |
#to_html ⇒ String
display colorset on IRuby notebook as a html table
64 65 66 67 68 69 70 71 |
# File 'lib/nyaplot/color.rb', line 64 def to_html html = '<table><tr>' @source.each{|color| html.concat("<th>" + color + "</th>")} html.concat("</tr><tr>") @source.each{|color| html.concat("<td style=\"background-color:" + color + ";\"> </td>")} html += '</tr></table>' return html end |
#to_json(*args) ⇒ Object
73 74 75 |
# File 'lib/nyaplot/color.rb', line 73 def to_json(*args) @source.to_json end |