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)


21
22
23
# File 'lib/convenient_service/support/value.rb', line 21

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

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



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

def label
  @label
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


29
30
31
32
33
# File 'lib/convenient_service/support/value.rb', line 29

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)


39
40
41
# File 'lib/convenient_service/support/value.rb', line 39

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

#eql?(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


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

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

  label == other.label
end

#hashInteger

Returns:

  • (Integer)


66
67
68
# File 'lib/convenient_service/support/value.rb', line 66

def hash
  [self.class, label].hash
end

#inspectString

Returns:

  • (String)


73
74
75
76
77
78
# File 'lib/convenient_service/support/value.rb', line 73

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

  label
end