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.



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

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

#blueObject



380
381
382
# File 'lib/asciimath/ast.rb', line 380

def blue
  value[:b]
end

#greenObject



376
377
378
# File 'lib/asciimath/ast.rb', line 376

def green
  value[:g]
end

#redObject



372
373
374
# File 'lib/asciimath/ast.rb', line 372

def red
  value[:r]
end

#to_hex_rgbObject



392
393
394
# File 'lib/asciimath/ast.rb', line 392

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

#to_sObject



396
397
398
# File 'lib/asciimath/ast.rb', line 396

def to_s
  text
end