Class: Antelope::Ace::Scanner::Argument

Inherits:
String
  • Object
show all
Defined in:
lib/antelope/ace/scanner/argument.rb

Overview

Represents an argument to a directive. It encapsulates a string object, which is the value of the argument.

Instance Method Summary collapse

Constructor Details

#initialize(type, value) ⇒ Argument

Initialize the argument.

Parameters:

  • type (Symbol)

    the type of argument it is; it can be a :block, :text, or :caret. The type is defined by the encapsulating characters. If the encapsulating characters are { and }, it's a :block; if they are < and >, it's a :caret; otherwise, it's a :text.

  • value (String)

    the value of the argument.



17
18
19
20
# File 'lib/antelope/ace/scanner/argument.rb', line 17

def initialize(type, value)
  @type = type
  super(value)
end

Instance Method Details

#block?Boolean

If this argument is type :block.

Returns:

  • (Boolean)

See Also:



26
27
28
# File 'lib/antelope/ace/scanner/argument.rb', line 26

def block?
  type? :block
end

#caret?Boolean

If this argument is type :caret.

Returns:

  • (Boolean)

See Also:



42
43
44
# File 'lib/antelope/ace/scanner/argument.rb', line 42

def caret?
  type? :caret
end

#text?Boolean

If this argument is type :text.

Returns:

  • (Boolean)

See Also:



34
35
36
# File 'lib/antelope/ace/scanner/argument.rb', line 34

def text?
  type? :text
end

#type?(*inc) ⇒ Boolean

Checks to see if any of the given arguments match the type of this argument.

Parameters:

  • inc (Array<Symbol>)

Returns:

  • (Boolean)


51
52
53
# File 'lib/antelope/ace/scanner/argument.rb', line 51

def type?(*inc)
  inc.include?(@type)
end