Class: Lisp::Format::Parameters::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/carat/lisp-format.rb

Overview

Base class from which the sub-classes get their behavior. Every parameter should sub-class from this class.

Direct Known Subclasses

Argument, ArgumentCount, Character, Default, Integer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pos, value = nil) ⇒ Parameter

Create a parameter, found at pos in the input format, and with value as its value - if it has one.



432
433
434
# File 'lib/carat/lisp-format.rb', line 432

def initialize(pos, value = nil)
  @pos, @value = pos, value
end

Instance Attribute Details

#posObject (readonly)

Position in the input format that this parameter was found.



443
444
445
# File 'lib/carat/lisp-format.rb', line 443

def pos
  @pos
end

Instance Method Details

#value(state, default) ⇒ Object

Retrieve this parameters value in the given State, using default if it is not defined.



438
439
440
# File 'lib/carat/lisp-format.rb', line 438

def value(state, default)
  @value or default
end