Class: Zenlish::Inflect::InflectionTableBuilder
- Inherits:
-
Object
- Object
- Zenlish::Inflect::InflectionTableBuilder
- Defined in:
- lib/zenlish/inflect/inflection_table_builder.rb
Instance Attribute Summary collapse
-
#conds ⇒ Object
readonly
Returns the value of attribute conds.
-
#headings ⇒ Object
readonly
Returns the value of attribute headings.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#table ⇒ Object
readonly
Name of decision table.
Instance Method Summary collapse
- #build(aTableName, &aBlock) ⇒ Object
- #col(aColName) ⇒ Object
- #concat(arg1, arg2) ⇒ Object
- #dont_care ⇒ Object
- #equals(aValue) ⇒ Object
- #feature_heading(aFeatureName) ⇒ Object
- #func(aFuncName) ⇒ Object
- #in?(*theMembers) ⇒ Boolean
-
#initialize ⇒ InflectionTableBuilder
constructor
A new instance of InflectionTableBuilder.
- #literal(aLiteral) ⇒ Object
- #matches(aPattern) ⇒ Object
- #method_heading(aMethodName) ⇒ Object
- #not_equal(aValue) ⇒ Object
- #rule(conditions, consequent) ⇒ Object
- #sub(original, pattern, replacement) ⇒ Object
Constructor Details
#initialize ⇒ InflectionTableBuilder
Returns a new instance of InflectionTableBuilder.
41 42 43 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 41 def initialize reset end |
Instance Attribute Details
#conds ⇒ Object (readonly)
Returns the value of attribute conds.
38 39 40 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 38 def conds @conds end |
#headings ⇒ Object (readonly)
Returns the value of attribute headings.
37 38 39 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 37 def headings @headings end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
39 40 41 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 39 def rules @rules end |
#table ⇒ Object (readonly)
Name of decision table
36 37 38 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 36 def table @table end |
Instance Method Details
#build(aTableName, &aBlock) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 45 def build(aTableName, &aBlock) reset @table = InflectionTable.new(aTableName) instance_exec(&aBlock) if block_given? @table end |
#col(aColName) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 108 def col(aColName) col_index = headings.find_index { |hd| hd.label == aColName } err_msg = "Cannot find heading named '#{aColName}'." raise StandardError, err_msg if col_index.nil? formal = FormalArgument.new(col_index) InputAsIs.new(formal) end |
#concat(arg1, arg2) ⇒ Object
132 133 134 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 132 def concat(arg1, arg2) Concatenation.new(arg1, arg2) end |
#dont_care ⇒ Object
97 98 99 100 101 102 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 97 def dont_care item = UnconditionallyTrue.new conds << item item end |
#equals(aValue) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 73 def equals(aValue) arg = FormalArgument.new(conds.size) equality_cond = EqualsLiteral.new(arg, aValue) conds << equality_cond equality_cond end |
#feature_heading(aFeatureName) ⇒ Object
52 53 54 55 56 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 52 def feature_heading(aFeatureName) hd = FeatureHeading.new(aFeatureName) headings << hd table&.add_heading(hd) end |
#func(aFuncName) ⇒ Object
124 125 126 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 124 def func(aFuncName) FunctionCall.new(aFuncName) end |
#in?(*theMembers) ⇒ Boolean
89 90 91 92 93 94 95 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 89 def in?(*theMembers) arg = FormalArgument.new(conds.size) membership_cond = Membership.new(arg, theMembers) conds << membership_cond membership_cond end |
#literal(aLiteral) ⇒ Object
104 105 106 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 104 def literal(aLiteral) LiteralAsIs.new(aLiteral) end |
#matches(aPattern) ⇒ Object
117 118 119 120 121 122 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 117 def matches(aPattern) arg = FormalArgument.new(conds.size) match_cond = MatchesPattern.new(arg, aPattern) conds << match_cond match_cond end |
#method_heading(aMethodName) ⇒ Object
58 59 60 61 62 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 58 def method_heading(aMethodName) hd = MethodHeading.new(aMethodName) headings << hd table&.add_heading(hd) end |
#not_equal(aValue) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 81 def not_equal(aValue) arg = FormalArgument.new(conds.size) inequality_cond = NotEqualsLiteral.new(arg, aValue) conds << inequality_cond inequality_cond end |
#rule(conditions, consequent) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 64 def rule(conditions, consequent) @conds = [] rl = InflectionRule.new(conditions.dup, consequent) rules << rl table&.add_rule(rl) rl end |
#sub(original, pattern, replacement) ⇒ Object
128 129 130 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 128 def sub(original, pattern, replacement) Substitution.new(original, pattern, replacement) end |