Class: Inform::Verb

Inherits:
Set show all
Defined in:
lib/story_teller/grammar_parser.rb

Overview

Verbs

Defined Under Namespace

Classes: Grammar

Constant Summary collapse

SpaceString =
' '.freeze
VerbString =
'Verb'.freeze
MetaString =
'meta'.freeze
EmoteString =
'emote'.freeze
Newline =
"\n".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Set

#ruby_to_s

Constructor Details

#initialize(verbs, source, meta = nil, emote = nil) ⇒ Verb

Returns a new instance of Verb.



51
52
53
54
55
56
57
58
# File 'lib/story_teller/grammar_parser.rb', line 51

def initialize(verbs, source, meta = nil, emote = nil)
  super()
  merge(verbs)
  @meta = meta unless meta.nil?
  @emote = emote unless emote.nil?
  @grammars = []
  @source = source
end

Instance Attribute Details

#emoteObject (readonly)

Returns the value of attribute emote.



48
49
50
# File 'lib/story_teller/grammar_parser.rb', line 48

def emote
  @emote
end

#grammarsObject

Returns the value of attribute grammars.



49
50
51
# File 'lib/story_teller/grammar_parser.rb', line 49

def grammars
  @grammars
end

#metaObject (readonly)

Returns the value of attribute meta.



48
49
50
# File 'lib/story_teller/grammar_parser.rb', line 48

def meta
  @meta
end

#sourceObject

Returns the value of attribute source.



49
50
51
# File 'lib/story_teller/grammar_parser.rb', line 49

def source
  @source
end

Instance Method Details

#<=>(other) ⇒ Object



65
66
67
68
# File 'lib/story_teller/grammar_parser.rb', line 65

def <=>(other)
  !other.nil? && include?(other.to_s) &&
    meta? == other.meta? && grammars == other.grammars && super
end

#==(other) ⇒ Object



60
61
62
63
# File 'lib/story_teller/grammar_parser.rb', line 60

def ==(other)
  !other.nil? && include?(other.to_s) &&
    meta? == other.meta? && grammars == other.grammars && super
end

#emote?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/story_teller/grammar_parser.rb', line 83

def emote?
  !emote.nil?
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
# File 'lib/story_teller/grammar_parser.rb', line 70

def eql?(other)
  !other.nil? && include?(other.to_s) &&
    meta? == other.meta? && grammars == other.grammars && super
end

#hashObject



107
108
109
# File 'lib/story_teller/grammar_parser.rb', line 107

def hash
  [super, meta, emote, grammars].hash
end

#meta?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/story_teller/grammar_parser.rb', line 79

def meta?
  !meta.nil?
end

#to_sObject Also known as: to_str



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/story_teller/grammar_parser.rb', line 93

def to_s
  VerbString + SpaceString +
    if meta?
      MetaString + SpaceString
    elsif emote?
      EmoteString + SpaceString
    else
      ''
    end +
    map { |verb| "'#{verb}'" }.join(SpaceString) + Newline +
    grammars.join(Newline)
end

#verbObject



75
76
77
# File 'lib/story_teller/grammar_parser.rb', line 75

def verb
  first
end