Class: AsciiMath::AST::Color

Inherits:
ValueNode show all
Defined in:
lib/asciimath/ast.rb

Instance Attribute Summary collapse

Attributes inherited from ValueNode

#value

Attributes inherited from Node

#parent

Instance Method Summary collapse

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

#textObject (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

#blueObject



382
383
384
# File 'lib/asciimath/ast.rb', line 382

def blue
  value[:b]
end

#greenObject



378
379
380
# File 'lib/asciimath/ast.rb', line 378

def green
  value[:g]
end

#redObject



374
375
376
# File 'lib/asciimath/ast.rb', line 374

def red
  value[:r]
end

#to_hex_rgbObject



394
395
396
# File 'lib/asciimath/ast.rb', line 394

def to_hex_rgb
  sprintf('#%02x%02x%02x', red, green, blue)
end

#to_sObject



398
399
400
# File 'lib/asciimath/ast.rb', line 398

def to_s
  text
end