Module: CEML::CastingStatement
- Extended by:
- Forwardable
- Defined in:
- lib/ceml/casting_statement.rb
Instance Method Summary collapse
- #matching_text ⇒ Object
- #max ⇒ Object
- #nab? ⇒ Boolean
- #over_phrase ⇒ Object
- #radius ⇒ Object
- #roles_to_cast(script) ⇒ Object
- #timewindow ⇒ Object
- #type ⇒ Object
- #with_matching_phrase ⇒ Object
- #within_phrase ⇒ Object
Instance Method Details
#matching_text ⇒ Object
41 42 43 |
# File 'lib/ceml/casting_statement.rb', line 41 def matching_text with_matching_phrase && with_matching_phrase.thing.text_value end |
#max ⇒ Object
22 23 24 |
# File 'lib/ceml/casting_statement.rb', line 22 def max roles.max end |
#nab? ⇒ Boolean
53 54 55 |
# File 'lib/ceml/casting_statement.rb', line 53 def nab? type == :nab end |
#over_phrase ⇒ Object
31 32 33 34 |
# File 'lib/ceml/casting_statement.rb', line 31 def over_phrase return if modifiers.empty? modifiers.elements.select{ |m| m.respond_to? :duration }.first end |
#radius ⇒ Object
49 50 51 |
# File 'lib/ceml/casting_statement.rb', line 49 def radius within_phrase && within_phrase.distance.meters end |
#roles_to_cast(script) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ceml/casting_statement.rb', line 7 def roles_to_cast(script) return [] unless type == :await roles.list.map do |r| matching = [] matching << matching_text if matching_text matching += [:city] if radius c = Criteria.new(r.qualifiers, [], matching, radius, timewindow) Role.new r.name, c, r.min..r.max, [] end end |
#timewindow ⇒ Object
45 46 47 |
# File 'lib/ceml/casting_statement.rb', line 45 def timewindow over_phrase && over_phrase.duration.seconds end |
#type ⇒ Object
18 19 20 |
# File 'lib/ceml/casting_statement.rb', line 18 def type elements.first.text_value.split.first.to_sym end |
#with_matching_phrase ⇒ Object
36 37 38 39 |
# File 'lib/ceml/casting_statement.rb', line 36 def with_matching_phrase return if modifiers.empty? modifiers.elements.select{ |m| m.respond_to? :thing }.first end |
#within_phrase ⇒ Object
26 27 28 29 |
# File 'lib/ceml/casting_statement.rb', line 26 def within_phrase return if modifiers.empty? modifiers.elements.select{ |m| m.respond_to? :distance }.first end |