Class: LanguageServer::Protocol::Interface::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/color.rb

Overview

Represents a color in RGBA space.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(red:, green:, blue:, alpha:) ⇒ Color

Returns a new instance of Color.



8
9
10
11
12
13
14
15
16
17
# File 'lib/language_server/protocol/interface/color.rb', line 8

def initialize(red:, green:, blue:, alpha:)
  @attributes = {}

  @attributes[:red] = red
  @attributes[:green] = green
  @attributes[:blue] = blue
  @attributes[:alpha] = alpha

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



51
52
53
# File 'lib/language_server/protocol/interface/color.rb', line 51

def attributes
  @attributes
end

Instance Method Details

#alphanumber

The alpha component of this color in the range [0-1].

Returns:

  • (number)


47
48
49
# File 'lib/language_server/protocol/interface/color.rb', line 47

def alpha
  attributes.fetch(:alpha)
end

#bluenumber

The blue component of this color in the range [0-1].

Returns:

  • (number)


39
40
41
# File 'lib/language_server/protocol/interface/color.rb', line 39

def blue
  attributes.fetch(:blue)
end

#greennumber

The green component of this color in the range [0-1].

Returns:

  • (number)


31
32
33
# File 'lib/language_server/protocol/interface/color.rb', line 31

def green
  attributes.fetch(:green)
end

#rednumber

The red component of this color in the range [0-1].

Returns:

  • (number)


23
24
25
# File 'lib/language_server/protocol/interface/color.rb', line 23

def red
  attributes.fetch(:red)
end

#to_hashObject



53
54
55
# File 'lib/language_server/protocol/interface/color.rb', line 53

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



57
58
59
# File 'lib/language_server/protocol/interface/color.rb', line 57

def to_json(*args)
  to_hash.to_json(*args)
end