Class: LanguageServer::Protocol::Interface::Color
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::Color
- Defined in:
- lib/language_server/protocol/interface/color.rb
Overview
Represents a color in RGBA space.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#alpha ⇒ number
The alpha component of this color in the range [0-1].
-
#blue ⇒ number
The blue component of this color in the range [0-1].
-
#green ⇒ number
The green component of this color in the range [0-1].
-
#initialize(red:, green:, blue:, alpha:) ⇒ Color
constructor
A new instance of Color.
-
#red ⇒ number
The red component of this color in the range [0-1].
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
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
#attributes ⇒ Object (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
#alpha ⇒ number
The alpha component of this color in the range [0-1].
47 48 49 |
# File 'lib/language_server/protocol/interface/color.rb', line 47 def alpha attributes.fetch(:alpha) end |
#blue ⇒ number
The blue component of this color in the range [0-1].
39 40 41 |
# File 'lib/language_server/protocol/interface/color.rb', line 39 def blue attributes.fetch(:blue) end |
#green ⇒ number
The green component of this color in the range [0-1].
31 32 33 |
# File 'lib/language_server/protocol/interface/color.rb', line 31 def green attributes.fetch(:green) end |
#red ⇒ number
The red component of this color in the range [0-1].
23 24 25 |
# File 'lib/language_server/protocol/interface/color.rb', line 23 def red attributes.fetch(:red) end |
#to_hash ⇒ Object
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 |