Class: RgGen::Core::InputBase::InputValue

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/rggen/core/input_base/input_value.rb

Constant Summary collapse

NoValue =
Object.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, options = NoValue, position) ⇒ InputValue

Returns a new instance of InputValue.



9
10
11
12
13
# File 'lib/rggen/core/input_base/input_value.rb', line 9

def initialize(value, options = NoValue, position)
  super((value.is_a?(String) && value.strip) || value)
  @options = options
  @position = position
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



18
19
20
# File 'lib/rggen/core/input_base/input_value.rb', line 18

def options
  @options
end

#positionObject (readonly)

Returns the value of attribute position.



17
18
19
# File 'lib/rggen/core/input_base/input_value.rb', line 17

def position
  @position
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
# File 'lib/rggen/core/input_base/input_value.rb', line 20

def ==(other)
  __getobj__ == other ||
    other.is_a?(InputValue) && __getobj__ == other.__getobj__
end

#available?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/rggen/core/input_base/input_value.rb', line 39

def available?
  true
end

#empty_value?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/rggen/core/input_base/input_value.rb', line 29

def empty_value?
  return true if value.nil?
  return true if value.respond_to?(:empty?) && value.empty?
  false
end

#match_class?(klass) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rggen/core/input_base/input_value.rb', line 25

def match_class?(klass)
  __getobj__.is_a?(klass)
end

#with_options?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rggen/core/input_base/input_value.rb', line 35

def with_options?
  !@options.equal?(NoValue)
end