Class: Inform::Verb
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
-
#emote ⇒ Object
readonly
Returns the value of attribute emote.
-
#grammars ⇒ Object
Returns the value of attribute grammars.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #emote? ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(verbs, source, meta = nil, emote = nil) ⇒ Verb
constructor
A new instance of Verb.
- #meta? ⇒ Boolean
- #to_s ⇒ Object (also: #to_str)
- #verb ⇒ Object
Methods inherited from Set
Constructor Details
#initialize(verbs, source, meta = nil, emote = nil) ⇒ Verb
Returns a new instance of Verb.
53 54 55 56 57 58 59 60 |
# File 'lib/runtime/grammar_parser.rb', line 53 def initialize(verbs, source, = nil, emote = nil) super() merge(verbs) @meta = unless .nil? @emote = emote unless emote.nil? @grammars = [] @source = source end |
Instance Attribute Details
#emote ⇒ Object (readonly)
Returns the value of attribute emote.
50 51 52 |
# File 'lib/runtime/grammar_parser.rb', line 50 def emote @emote end |
#grammars ⇒ Object
Returns the value of attribute grammars.
51 52 53 |
# File 'lib/runtime/grammar_parser.rb', line 51 def grammars @grammars end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
50 51 52 |
# File 'lib/runtime/grammar_parser.rb', line 50 def @meta end |
#source ⇒ Object
Returns the value of attribute source.
51 52 53 |
# File 'lib/runtime/grammar_parser.rb', line 51 def source @source end |
Instance Method Details
#<=>(other) ⇒ Object
67 68 69 70 |
# File 'lib/runtime/grammar_parser.rb', line 67 def <=>(other) !other.nil? && include?(other.to_s) && == other. && grammars == other.grammars && super end |
#==(other) ⇒ Object
62 63 64 65 |
# File 'lib/runtime/grammar_parser.rb', line 62 def ==(other) !other.nil? && include?(other.to_s) && == other. && grammars == other.grammars && super end |
#emote? ⇒ Boolean
85 86 87 |
# File 'lib/runtime/grammar_parser.rb', line 85 def emote? !emote.nil? end |
#eql?(other) ⇒ Boolean
72 73 74 75 |
# File 'lib/runtime/grammar_parser.rb', line 72 def eql?(other) !other.nil? && include?(other.to_s) && == other. && grammars == other.grammars && super end |
#hash ⇒ Object
109 110 111 |
# File 'lib/runtime/grammar_parser.rb', line 109 def hash [super, , emote, grammars].hash end |
#meta? ⇒ Boolean
81 82 83 |
# File 'lib/runtime/grammar_parser.rb', line 81 def !.nil? end |
#to_s ⇒ Object Also known as: to_str
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/runtime/grammar_parser.rb', line 95 def to_s VerbString + SpaceString + if MetaString + SpaceString elsif emote? EmoteString + SpaceString else '' end + map { |verb| "'#{verb}'" }.join(SpaceString) + Newline + grammars.map(&:to_s).join(Newline) end |
#verb ⇒ Object
77 78 79 |
# File 'lib/runtime/grammar_parser.rb', line 77 def verb first end |