Class: ActiveFacts::CQL::Verbaliser::Player
- Inherits:
-
Object
- Object
- ActiveFacts::CQL::Verbaliser::Player
- Defined in:
- lib/activefacts/cql/verbaliser.rb
Instance Attribute Summary collapse
-
#object_type ⇒ Object
Returns the value of attribute object_type.
-
#plays ⇒ Object
Returns the value of attribute plays.
-
#role_refs ⇒ Object
Returns the value of attribute role_refs.
-
#subscript ⇒ Object
Returns the value of attribute subscript.
-
#variables_by_query ⇒ Object
Returns the value of attribute variables_by_query.
Instance Method Summary collapse
- #describe ⇒ Object
-
#initialize(object_type) ⇒ Player
constructor
A new instance of Player.
-
#role_adjuncts(matching) ⇒ Object
What words are used (across all roles) for disambiguating the references to this player? If more than one set of adjectives was used, this player must have been subject to loose binding.
Constructor Details
#initialize(object_type) ⇒ Player
Returns a new instance of Player.
103 104 105 106 107 108 109 |
# File 'lib/activefacts/cql/verbaliser.rb', line 103 def initialize object_type @object_type = object_type @variables_by_query = {} @subscript = nil @plays = [] @role_refs = [] end |
Instance Attribute Details
#object_type ⇒ Object
Returns the value of attribute object_type.
102 103 104 |
# File 'lib/activefacts/cql/verbaliser.rb', line 102 def object_type @object_type end |
#plays ⇒ Object
Returns the value of attribute plays.
102 103 104 |
# File 'lib/activefacts/cql/verbaliser.rb', line 102 def plays @plays end |
#role_refs ⇒ Object
Returns the value of attribute role_refs.
102 103 104 |
# File 'lib/activefacts/cql/verbaliser.rb', line 102 def role_refs @role_refs end |
#subscript ⇒ Object
Returns the value of attribute subscript.
102 103 104 |
# File 'lib/activefacts/cql/verbaliser.rb', line 102 def subscript @subscript end |
#variables_by_query ⇒ Object
Returns the value of attribute variables_by_query.
102 103 104 |
# File 'lib/activefacts/cql/verbaliser.rb', line 102 def variables_by_query @variables_by_query end |
Instance Method Details
#describe ⇒ Object
129 130 131 |
# File 'lib/activefacts/cql/verbaliser.rb', line 129 def describe @object_type.name + (@variables_by_query.size > 0 ? " (in #{@variables_by_query.size} variables)" : "") end |
#role_adjuncts(matching) ⇒ Object
What words are used (across all roles) for disambiguating the references to this player? If more than one set of adjectives was used, this player must have been subject to loose binding. This method is used to decide when subscripts aren’t needed.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/activefacts/cql/verbaliser.rb', line 114 def role_adjuncts matching if matching == :loose adjuncts = [] else adjuncts = @role_refs.map{|rr| [ rr.leading_adjective, matching == :rolenames ? rr.role.role_name : nil, rr.trailing_adjective ].compact}.uniq.sort end adjuncts += [@variables_by_query.values.map{|jn| jn.role_name}.compact[0]].compact adjuncts.flatten*"_" end |