Class: RgGen::Core::InputBase::Feature

Inherits:
Base::Feature show all
Includes:
ConversionUtility, Utility::RegexpPatterns, Utility::TypeChecker
Defined in:
lib/rggen/core/input_base/feature.rb

Direct Known Subclasses

Configuration::Feature, RegisterMap::Feature

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from Base::Feature

#component

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utility::RegexpPatterns

included

Methods inherited from Base::Feature

#feature_name, #initialize

Methods included from Base::SharedContext

#attach_context

Constructor Details

This class inherits a constructor from RgGen::Core::Base::Feature

Class Attribute Details

.buildersObject (readonly)

Returns the value of attribute builders.



36
37
38
# File 'lib/rggen/core/input_base/feature.rb', line 36

def builders
  @builders
end

.input_matcherObject (readonly)

Returns the value of attribute input_matcher.



56
57
58
# File 'lib/rggen/core/input_base/feature.rb', line 56

def input_matcher
  @input_matcher
end

.post_buildersObject (readonly)

Returns the value of attribute post_builders.



42
43
44
# File 'lib/rggen/core/input_base/feature.rb', line 42

def post_builders
  @post_builders
end

.printablesObject (readonly)

Returns the value of attribute printables.



69
70
71
# File 'lib/rggen/core/input_base/feature.rb', line 69

def printables
  @printables
end

.verifiersObject (readonly)

Returns the value of attribute verifiers.



63
64
65
# File 'lib/rggen/core/input_base/feature.rb', line 63

def verifiers
  @verifiers
end

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



124
125
126
# File 'lib/rggen/core/input_base/feature.rb', line 124

def position
  @position
end

Class Method Details

.active_feature?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/rggen/core/input_base/feature.rb', line 44

def active_feature?
  !passive_feature?
end

.build(&block) ⇒ Object



32
33
34
# File 'lib/rggen/core/input_base/feature.rb', line 32

def build(&block)
  (@builders ||= []) << block
end

.ignore_empty_value(value = nil) ⇒ Object



23
24
25
26
# File 'lib/rggen/core/input_base/feature.rb', line 23

def ignore_empty_value(value = nil)
  @ignore_empty_value = value unless value.nil?
  @ignore_empty_value
end

.ignore_empty_value?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rggen/core/input_base/feature.rb', line 28

def ignore_empty_value?
  @ignore_empty_value.nil? || @ignore_empty_value
end

.inherited(subclass) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/rggen/core/input_base/feature.rb', line 71

def inherited(subclass)
  super
  export_instance_variable(:@properties, subclass, &:dup)
  export_instance_variable(:@ignore_empty_value, subclass)
  export_instance_variable(:@builders, subclass, &:dup)
  export_instance_variable(:@post_builders, subclass, &:dup)
  export_instance_variable(:@input_matcher, subclass)
  export_instance_variable(:@printables, subclass, &:dup)
  export_verifiers(subclass) if @verifiers
end

.input_pattern(pattern_or_patterns) ⇒ Object



52
53
54
# File 'lib/rggen/core/input_base/feature.rb', line 52

def input_pattern(pattern_or_patterns, ...)
  @input_matcher = InputMatcher.new(pattern_or_patterns, ...)
end

.passive_feature?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/rggen/core/input_base/feature.rb', line 48

def passive_feature?
  builders.nil?
end

.post_build(&block) ⇒ Object



38
39
40
# File 'lib/rggen/core/input_base/feature.rb', line 38

def post_build(&block)
  (@post_builders ||= []) << block
end

.printable(name, &body) ⇒ Object



65
66
67
# File 'lib/rggen/core/input_base/feature.rb', line 65

def printable(name, &body)
  (@printables ||= {})[name] = body
end

.propertiesObject



19
20
21
# File 'lib/rggen/core/input_base/feature.rb', line 19

def properties
  @properties ||= []
end

.property(name) ⇒ Object Also known as: field



12
13
14
15
# File 'lib/rggen/core/input_base/feature.rb', line 12

def property(name, ...)
  Property.define(self, name, ...)
  properties.include?(name) || properties << name
end

.verify(scope, &block) ⇒ Object



58
59
60
61
# File 'lib/rggen/core/input_base/feature.rb', line 58

def verify(scope, &block)
  @verifiers ||= {}
  (@verifiers[scope] ||= []) << create_verifier(&block)
end

Instance Method Details

#build(*args) ⇒ Object



99
100
101
# File 'lib/rggen/core/input_base/feature.rb', line 99

def build(*args)
  self.class.builders && do_build(args)
end

#error_positionObject



126
127
128
129
130
131
132
133
134
# File 'lib/rggen/core/input_base/feature.rb', line 126

def error_position
  if position
    position
  else
    approximate_position =
      component.features.map(&:position).find(&:itself)
    ApproximatelyErrorPosition.create(approximate_position)
  end
end

#inspectObject



119
120
121
122
# File 'lib/rggen/core/input_base/feature.rb', line 119

def inspect
  printable_values = printables&.map { |name, value| "#{name}: #{value.inspect}" }
  (printable_values && "#{super}[#{printable_values.join(', ')}]") || super
end

#post_buildObject



103
104
105
# File 'lib/rggen/core/input_base/feature.rb', line 103

def post_build
  self.class.post_builders&.each { |block| instance_exec(&block) }
end

#printable?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/rggen/core/input_base/feature.rb', line 115

def printable?
  !helper.printables.nil?
end

#printablesObject



111
112
113
# File 'lib/rggen/core/input_base/feature.rb', line 111

def printables
  helper.printables&.map { |name, body| [name, printable(name, &body)] }
end

#verify(scope) ⇒ Object



107
108
109
# File 'lib/rggen/core/input_base/feature.rb', line 107

def verify(scope)
  verified?(scope) || do_verify(scope)
end