Class: SentenceBuilder::BaseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/sentence_builder/base_node.rb

Direct Known Subclasses

SentenceNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ BaseNode

Returns a new instance of BaseNode.



5
6
7
8
9
# File 'lib/sentence_builder/base_node.rb', line 5

def initialize(name, options = {})
  @name = name.to_sym
  @options = options
  @default = @options[:default] || nil
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



3
4
5
# File 'lib/sentence_builder/base_node.rb', line 3

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/sentence_builder/base_node.rb', line 3

def name
  @name
end

Instance Method Details

#prefixObject



11
12
13
# File 'lib/sentence_builder/base_node.rb', line 11

def prefix
  @options[:prefix] || ''
end

#prefix=(new_prefix) ⇒ Object



15
16
17
# File 'lib/sentence_builder/base_node.rb', line 15

def prefix=(new_prefix)
  @options[:prefix] = new_prefix || ''
end

#suffixObject



19
20
21
# File 'lib/sentence_builder/base_node.rb', line 19

def suffix
  @options[:suffix] || ''
end

#suffix=(new_suffix) ⇒ Object



23
24
25
# File 'lib/sentence_builder/base_node.rb', line 23

def suffix=(new_suffix)
  @options[:suffix] = new_suffix || ''
end