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.
369 370 371 372 |
# File 'lib/asciimath/ast.rb', line 369 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.
367 368 369 |
# File 'lib/asciimath/ast.rb', line 367 def text @text end |
Instance Method Details
#==(o) ⇒ Object
386 387 388 389 390 391 392 |
# File 'lib/asciimath/ast.rb', line 386 def ==(o) o.class == self.class && o.red == red && o.green == green && o.blue == blue && o.text == text end |
#blue ⇒ Object
382 383 384 |
# File 'lib/asciimath/ast.rb', line 382 def blue value[:b] end |
#green ⇒ Object
378 379 380 |
# File 'lib/asciimath/ast.rb', line 378 def green value[:g] end |
#red ⇒ Object
374 375 376 |
# File 'lib/asciimath/ast.rb', line 374 def red value[:r] end |
#to_hex_rgb ⇒ Object
394 395 396 |
# File 'lib/asciimath/ast.rb', line 394 def to_hex_rgb sprintf('#%02x%02x%02x', red, green, blue) end |
#to_s ⇒ Object
398 399 400 |
# File 'lib/asciimath/ast.rb', line 398 def to_s text end |