Class: ActiveFacts::Metamodel::Verbaliser::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/activefacts/vocabulary/verbaliser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(concept) ⇒ Player

Returns a new instance of Player.



103
104
105
106
107
108
109
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 103

def initialize concept
  @concept = concept
  @join_nodes_by_join = {}
  @subscript = nil
  @join_roles = []
  @role_refs = []
end

Instance Attribute Details

#conceptObject

Returns the value of attribute concept.



102
103
104
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 102

def concept
  @concept
end

#join_nodes_by_joinObject

Returns the value of attribute join_nodes_by_join.



102
103
104
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 102

def join_nodes_by_join
  @join_nodes_by_join
end

#join_rolesObject

Returns the value of attribute join_roles.



102
103
104
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 102

def join_roles
  @join_roles
end

#role_refsObject

Returns the value of attribute role_refs.



102
103
104
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 102

def role_refs
  @role_refs
end

#subscriptObject

Returns the value of attribute subscript.



102
103
104
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 102

def subscript
  @subscript
end

Instance Method Details

#describeObject



124
125
126
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 124

def describe
  @concept.name + (@join_nodes_by_join.size > 0 ? " (in #{@join_nodes_by_join.size} joins)" : "")
end

#role_adjunctsObject

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
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 114

def role_adjuncts
  adjuncts = @role_refs.map{|rr|
    [
      rr.leading_adjective,
      # rr.role.role_name,
      rr.trailing_adjective
    ].compact}.uniq.sort
  adjuncts.flatten*"_"
end