Class: Jsapi::Meta::Schema::Boundary

Inherits:
Object
  • Object
show all
Defined in:
lib/jsapi/meta/schema/boundary.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, exclusive: false) ⇒ Boundary

Returns a new instance of Boundary.



22
23
24
25
# File 'lib/jsapi/meta/schema/boundary.rb', line 22

def initialize(value, exclusive: false)
  @value = value
  @exclusive = exclusive
end

Instance Attribute Details

#valueObject (readonly)

The value of the boundary.



20
21
22
# File 'lib/jsapi/meta/schema/boundary.rb', line 20

def value
  @value
end

Class Method Details

.from(value) ⇒ Object

Transforms value to an instance of this class.



8
9
10
11
12
13
14
15
16
17
# File 'lib/jsapi/meta/schema/boundary.rb', line 8

def self.from(value)
  case value
  when Boundary
    value
  when Hash
    Boundary.new(value[:value], exclusive: value[:exclusive] == true)
  else
    Boundary.new(value)
  end
end

Instance Method Details

#exclusive?Boolean

Returns true if the boundary is exclusive, false otherwise.

Returns:



28
29
30
# File 'lib/jsapi/meta/schema/boundary.rb', line 28

def exclusive?
  @exclusive == true
end

#inspectObject

:nodoc:



32
33
34
# File 'lib/jsapi/meta/schema/boundary.rb', line 32

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