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.
39 40 41 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 39 def initialize reset end |
Instance Attribute Details
#conds ⇒ Object (readonly)
Returns the value of attribute conds.
36 37 38 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 36 def conds @conds end |
#headings ⇒ Object (readonly)
Returns the value of attribute headings.
35 36 37 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 35 def headings @headings end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
37 38 39 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 37 def rules @rules end |
#table ⇒ Object (readonly)
Name of decision table
34 35 36 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 34 def table @table end |
Instance Method Details
#build(aTableName, &aBlock) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 43 def build(aTableName, &aBlock) reset @table = InflectionTable.new(aTableName) instance_exec(&aBlock) if block_given? @table end |
#col(aColName) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 106 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
129 130 131 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 129 def concat(arg1, arg2) Concatenation.new(arg1, arg2) end |
#dont_care ⇒ Object
95 96 97 98 99 100 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 95 def dont_care item = UnconditionallyTrue.new conds << item item end |
#equals(aValue) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 71 def equals(aValue) arg = FormalArgument.new(conds.size) equality_cond = EqualsLiteral.new(arg, aValue) conds << equality_cond equality_cond end |
#feature_heading(aFeatureName) ⇒ Object
50 51 52 53 54 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 50 def feature_heading(aFeatureName) hd = FeatureHeading.new(aFeatureName) headings << hd table.add_heading(hd) if table end |
#func(aFuncName) ⇒ Object
121 122 123 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 121 def func(aFuncName) FunctionCall.new(aFuncName) end |
#in?(*theMembers) ⇒ Boolean
87 88 89 90 91 92 93 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 87 def in?(*theMembers) arg = FormalArgument.new(conds.size) membership_cond = Membership.new(arg, theMembers) conds << membership_cond membership_cond end |
#literal(aLiteral) ⇒ Object
102 103 104 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 102 def literal(aLiteral) LiteralAsIs.new(aLiteral) end |
#matches(aPattern) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 114 def matches(aPattern) arg = FormalArgument.new(conds.size) match_cond = MatchesPattern.new(arg, aPattern) conds << match_cond match_cond end |
#method_heading(aMethodName) ⇒ Object
56 57 58 59 60 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 56 def method_heading(aMethodName) hd = MethodHeading.new(aMethodName) headings << hd table.add_heading(hd) if table end |
#not_equal(aValue) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 79 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
62 63 64 65 66 67 68 69 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 62 def rule(conditions, consequent) @conds = [] rl = InflectionRule.new(conditions.dup, consequent) rules << rl table.add_rule(rl) if table rl end |
#sub(original, pattern, replacement) ⇒ Object
125 126 127 |
# File 'lib/zenlish/inflect/inflection_table_builder.rb', line 125 def sub(original, pattern, replacement) Substitution.new(original, pattern, replacement) end |