Class: Nyaplot::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/nyaplot/color.rb

Overview

The html interface to access Colorset

Instance Method Summary collapse

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_aObject



58
59
60
# File 'lib/nyaplot/color.rb', line 58

def to_a
  @source
end

#to_htmlString

display colorset on IRuby notebook as a html table

Returns:

  • (String)

    generated html



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 + ";\">&nbsp;</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