Class: ConvenientService::Support::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/support/value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label = default_label) ⇒ void

Parameters:

  • label (String) (defaults to: default_label)


16
17
18
# File 'lib/convenient_service/support/value.rb', line 16

def initialize(label = default_label)
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



10
11
12
# File 'lib/convenient_service/support/value.rb', line 10

def label
  @label
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


24
25
26
27
28
# File 'lib/convenient_service/support/value.rb', line 24

def ==(other)
  return unless other.instance_of?(self.class)

  label == other.label
end

#===(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


34
35
36
# File 'lib/convenient_service/support/value.rb', line 34

def ===(other)
  self == other
end

#eql?(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


42
43
44
45
46
# File 'lib/convenient_service/support/value.rb', line 42

def eql?(other)
  return unless other.instance_of?(self.class)

  hash == other.hash
end

#hashInteger

Returns:

  • (Integer)


54
55
56
# File 'lib/convenient_service/support/value.rb', line 54

def hash
  label.hash
end

#inspectString

Returns:

  • (String)


61
62
63
64
65
66
# File 'lib/convenient_service/support/value.rb', line 61

def inspect
  return default_label if label.nil?
  return default_label if label.empty?

  label
end