Class: Ruflet::IconData

Inherits:
Object
  • Object
show all
Defined in:
lib/ruflet_ui/ruflet/icon_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ IconData

Returns a new instance of IconData.



14
15
16
# File 'lib/ruflet_ui/ruflet/icon_data.rb', line 14

def initialize(value)
  @value = normalize(value)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



12
13
14
# File 'lib/ruflet_ui/ruflet/icon_data.rb', line 12

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/ruflet_ui/ruflet/icon_data.rb', line 18

def ==(other)
  other_value = other.is_a?(IconData) ? other.value : self.class.new(other).value
  if value.is_a?(Integer) && other_value.is_a?(Integer)
    value == other_value
  elsif value.is_a?(String) && other_value.is_a?(String)
    value.casecmp?(other_value)
  else
    value == other_value
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/ruflet_ui/ruflet/icon_data.rb', line 29

def eql?(other)
  self == other
end

#hashObject



33
34
35
# File 'lib/ruflet_ui/ruflet/icon_data.rb', line 33

def hash
  value.is_a?(String) ? value.downcase.hash : value.hash
end

#to_sObject



37
38
39
# File 'lib/ruflet_ui/ruflet/icon_data.rb', line 37

def to_s
  value.to_s
end