Module: CEML::CastingStatement

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

Instance Method Summary collapse

Instance Method Details

#casting_specObject



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

Returns:

  • (Boolean)


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

def live_casting?
  [:await, :accept].include?(type)
end

#matching_textObject



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

#maxObject



27
28
29
# File 'lib/ceml/lang/casting_statement.rb', line 27

def max
  roles.max
end

#nab?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/ceml/lang/casting_statement.rb', line 63

def nab?
  type == :nab
end

#over_phraseObject



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

#radiusObject



59
60
61
# File 'lib/ceml/lang/casting_statement.rb', line 59

def radius
  within_phrase && within_phrase.distance.meters
end

#stanza_nameObject



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

#timewindowObject



55
56
57
# File 'lib/ceml/lang/casting_statement.rb', line 55

def timewindow
  over_phrase && over_phrase.duration.seconds
end

#typeObject



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_phraseObject



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_phraseObject



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