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)
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength.
- #verb ⇒ Object
Methods inherited from Set
Constructor Details
#initialize(verbs, source, meta = nil, emote = nil) ⇒ Verb
Returns a new instance of Verb.
52 53 54 55 56 57 58 59 |
# File 'lib/story_teller/grammar_parser.rb', line 52 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.
49 50 51 |
# File 'lib/story_teller/grammar_parser.rb', line 49 def emote @emote end |
#grammars ⇒ Object
Returns the value of attribute grammars.
50 51 52 |
# File 'lib/story_teller/grammar_parser.rb', line 50 def grammars @grammars end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
49 50 51 |
# File 'lib/story_teller/grammar_parser.rb', line 49 def @meta end |
#source ⇒ Object
Returns the value of attribute source.
50 51 52 |
# File 'lib/story_teller/grammar_parser.rb', line 50 def source @source end |
Instance Method Details
#<=>(other) ⇒ Object
66 67 68 69 |
# File 'lib/story_teller/grammar_parser.rb', line 66 def <=>(other) !other.nil? && include?(other.to_s) && == other. && grammars == other.grammars && super end |
#==(other) ⇒ Object
61 62 63 64 |
# File 'lib/story_teller/grammar_parser.rb', line 61 def ==(other) !other.nil? && include?(other.to_s) && == other. && grammars == other.grammars && super end |
#emote? ⇒ Boolean
84 85 86 |
# File 'lib/story_teller/grammar_parser.rb', line 84 def emote? !emote.nil? end |
#eql?(other) ⇒ Boolean
71 72 73 74 |
# File 'lib/story_teller/grammar_parser.rb', line 71 def eql?(other) !other.nil? && include?(other.to_s) && == other. && grammars == other.grammars && super end |
#hash ⇒ Object
115 116 117 |
# File 'lib/story_teller/grammar_parser.rb', line 115 def hash [super, , emote, grammars].hash end |
#meta? ⇒ Boolean
80 81 82 |
# File 'lib/story_teller/grammar_parser.rb', line 80 def !.nil? end |
#to_s ⇒ Object Also known as: to_str
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/story_teller/grammar_parser.rb', line 96 def to_s grammar_lines = grammars.map(&:to_s) grammar_lines[-1] = "#{grammar_lines[-1]};" if grammar_lines.any? VerbString + SpaceString + if MetaString + SpaceString elsif emote? EmoteString + SpaceString else '' end + map { |verb| "'#{verb}'" }.join(SpaceString) + Newline + grammar_lines.join(Newline) end |
#verb ⇒ Object
76 77 78 |
# File 'lib/story_teller/grammar_parser.rb', line 76 def verb first end |