Class: Jsapi::Status::Base

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/jsapi/status/base.rb

Direct Known Subclasses

Code, Range

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, priority:) ⇒ Base

Returns a new instance of Base.



12
13
14
15
# File 'lib/jsapi/status/base.rb', line 12

def initialize(value, priority:)
  @priority = priority
  @value = value
end

Instance Attribute Details

#priorityObject (readonly)

Returns the value of attribute priority.



8
9
10
# File 'lib/jsapi/status/base.rb', line 8

def priority
  @priority
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/jsapi/status/base.rb', line 8

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object

:nodoc:



23
24
25
26
27
28
# File 'lib/jsapi/status/base.rb', line 23

def <=>(other) # :nodoc:
  result = priority <=> other.priority
  return result unless result.zero?

  value <=> other.value
end

#==(other) ⇒ Object Also known as: eql?

:nodoc:



17
18
19
# File 'lib/jsapi/status/base.rb', line 17

def ==(other) # :nodoc:
  other.is_a?(self.class) && other.value == value
end

#inspectObject

:nodoc:



30
31
32
# File 'lib/jsapi/status/base.rb', line 30

def inspect # :nodoc:
  "#<#{self.class} #{value.inspect}>"
end