Class: AsciiMath::AST::Color
- Defined in:
- lib/asciimath/ast.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from ValueNode
Attributes inherited from Node
Instance Method Summary collapse
- #==(o) ⇒ Object
- #blue ⇒ Object
- #green ⇒ Object
-
#initialize(r, g, b, text) ⇒ Color
constructor
A new instance of Color.
- #red ⇒ Object
- #to_hex_rgb ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(r, g, b, text) ⇒ Color
Returns a new instance of Color.
367 368 369 370 |
# File 'lib/asciimath/ast.rb', line 367 def initialize(r, g, b, text) super({:r => r, :g => g, :b => b}.freeze) @text = text.dup.freeze end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
365 366 367 |
# File 'lib/asciimath/ast.rb', line 365 def text @text end |
Instance Method Details
#==(o) ⇒ Object
384 385 386 387 388 389 390 |
# File 'lib/asciimath/ast.rb', line 384 def ==(o) o.class == self.class && o.red == red && o.green == green && o.blue == blue && o.text == text end |
#blue ⇒ Object
380 381 382 |
# File 'lib/asciimath/ast.rb', line 380 def blue value[:b] end |
#green ⇒ Object
376 377 378 |
# File 'lib/asciimath/ast.rb', line 376 def green value[:g] end |
#red ⇒ Object
372 373 374 |
# File 'lib/asciimath/ast.rb', line 372 def red value[:r] end |
#to_hex_rgb ⇒ Object
392 393 394 |
# File 'lib/asciimath/ast.rb', line 392 def to_hex_rgb sprintf('#%02x%02x%02x', red, green, blue) end |
#to_s ⇒ Object
396 397 398 |
# File 'lib/asciimath/ast.rb', line 396 def to_s text end |