Module: CEML::CastingStatement

Extended by:
Forwardable
Defined in:
lib/ceml/casting_statement.rb

Instance Method Summary collapse

Instance Method Details

#matching_textObject



41
42
43
# File 'lib/ceml/casting_statement.rb', line 41

def matching_text
  with_matching_phrase && with_matching_phrase.thing.text_value
end

#maxObject



22
23
24
# File 'lib/ceml/casting_statement.rb', line 22

def max
  roles.max
end

#nab?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/ceml/casting_statement.rb', line 53

def nab?
  type == :nab
end

#over_phraseObject



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

#radiusObject



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

#timewindowObject



45
46
47
# File 'lib/ceml/casting_statement.rb', line 45

def timewindow
  over_phrase && over_phrase.duration.seconds
end

#typeObject



18
19
20
# File 'lib/ceml/casting_statement.rb', line 18

def type
  elements.first.text_value.split.first.to_sym
end

#with_matching_phraseObject



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_phraseObject



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