Module: CEML::CastingStatement
- Extended by:
- Forwardable
- Defined in:
- lib/ceml/lang/casting_statement.rb
Instance Method Summary collapse
- #casting_spec ⇒ Object
- #live_casting? ⇒ Boolean
- #matching_text ⇒ Object
- #max ⇒ Object
- #nab? ⇒ Boolean
- #over_phrase ⇒ Object
- #radius ⇒ Object
- #stanza_name ⇒ Object
- #timewindow ⇒ Object
- #type ⇒ Object
- #with_matching_phrase ⇒ Object
- #within_phrase ⇒ Object
Instance Method Details
#casting_spec ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ceml/lang/casting_statement.rb', line 8 def casting_spec return nil unless live_casting? matching = [] matching << matching_text.to_sym if matching_text matching += [:city] if radius rolespecs = roles.list.map do |r| RoleSpec.new(r.name, Tagspec.new(r.qualifiers,[]), r.min..r.max) end [type, stanza_name, matching, radius, timewindow, rolespecs] end |
#live_casting? ⇒ Boolean
23 24 25 |
# File 'lib/ceml/lang/casting_statement.rb', line 23 def live_casting? [:await, :accept].include?(type) end |
#matching_text ⇒ Object
51 52 53 |
# File 'lib/ceml/lang/casting_statement.rb', line 51 def matching_text with_matching_phrase && with_matching_phrase.thing.text_value end |
#max ⇒ Object
27 28 29 |
# File 'lib/ceml/lang/casting_statement.rb', line 27 def max roles.max end |
#nab? ⇒ Boolean
63 64 65 |
# File 'lib/ceml/lang/casting_statement.rb', line 63 def nab? type == :nab end |
#over_phrase ⇒ Object
41 42 43 44 |
# File 'lib/ceml/lang/casting_statement.rb', line 41 def over_phrase return if modifiers.empty? modifiers.elements.select{ |m| m.respond_to? :duration }.first end |
#radius ⇒ Object
59 60 61 |
# File 'lib/ceml/lang/casting_statement.rb', line 59 def radius within_phrase && within_phrase.distance.meters end |
#stanza_name ⇒ Object
31 32 33 34 |
# File 'lib/ceml/lang/casting_statement.rb', line 31 def stanza_name return nil if stanza_marker.empty? stanza_marker and stanza_marker.name and stanza_marker.name.text_value end |
#timewindow ⇒ Object
55 56 57 |
# File 'lib/ceml/lang/casting_statement.rb', line 55 def timewindow over_phrase && over_phrase.duration.seconds end |
#type ⇒ Object
19 20 21 |
# File 'lib/ceml/lang/casting_statement.rb', line 19 def type elements[1].text_value.split.first.to_sym end |
#with_matching_phrase ⇒ Object
46 47 48 49 |
# File 'lib/ceml/lang/casting_statement.rb', line 46 def with_matching_phrase return if modifiers.empty? modifiers.elements.select{ |m| m.respond_to? :thing }.first end |
#within_phrase ⇒ Object
36 37 38 39 |
# File 'lib/ceml/lang/casting_statement.rb', line 36 def within_phrase return if modifiers.empty? modifiers.elements.select{ |m| m.respond_to? :distance }.first end |