Class: RgGen::Core::InputBase::Feature
Class Attribute Summary collapse
Instance Attribute Summary collapse
#component
Class Method Summary
collapse
Instance Method Summary
collapse
included
#feature_name, #initialize
#attach_context
Class Attribute Details
Returns the value of attribute builders.
36
37
38
|
# File 'lib/rggen/core/input_base/feature.rb', line 36
def builders
@builders
end
|
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_builders ⇒ Object
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
|
.printables ⇒ Object
Returns the value of attribute printables.
69
70
71
|
# File 'lib/rggen/core/input_base/feature.rb', line 69
def printables
@printables
end
|
.verifiers ⇒ Object
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
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
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
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
|
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
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
|
.properties ⇒ Object
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_position ⇒ Object
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
|
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_build ⇒ Object
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
115
116
117
|
# File 'lib/rggen/core/input_base/feature.rb', line 115
def printable?
!helper.printables.nil?
end
|
#printables ⇒ Object
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
|