Class: WolfTrans::Context::MapEvent
- Inherits:
-
WolfTrans::Context
- Object
- WolfTrans::Context
- WolfTrans::Context::MapEvent
- Defined in:
- lib/wolftrans/context.rb
Instance Attribute Summary collapse
-
#command_name ⇒ Object
readonly
Returns the value of attribute command_name.
-
#event_num ⇒ Object
readonly
Returns the value of attribute event_num.
-
#line_num ⇒ Object
readonly
Returns the value of attribute line_num.
-
#map_name ⇒ Object
readonly
Returns the value of attribute map_name.
-
#page_num ⇒ Object
readonly
Returns the value of attribute page_num.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(map_name, event_num, page_num, line_num, command_name) ⇒ MapEvent
constructor
A new instance of MapEvent.
- #to_s ⇒ Object
Constructor Details
#initialize(map_name, event_num, page_num, line_num, command_name) ⇒ MapEvent
Returns a new instance of MapEvent.
37 38 39 40 41 42 43 |
# File 'lib/wolftrans/context.rb', line 37 def initialize(map_name, event_num, page_num, line_num, command_name) @map_name = map_name @event_num = event_num @page_num = page_num @line_num = line_num @command_name = command_name end |
Instance Attribute Details
#command_name ⇒ Object (readonly)
Returns the value of attribute command_name.
35 36 37 |
# File 'lib/wolftrans/context.rb', line 35 def command_name @command_name end |
#event_num ⇒ Object (readonly)
Returns the value of attribute event_num.
32 33 34 |
# File 'lib/wolftrans/context.rb', line 32 def event_num @event_num end |
#line_num ⇒ Object (readonly)
Returns the value of attribute line_num.
34 35 36 |
# File 'lib/wolftrans/context.rb', line 34 def line_num @line_num end |
#map_name ⇒ Object (readonly)
Returns the value of attribute map_name.
31 32 33 |
# File 'lib/wolftrans/context.rb', line 31 def map_name @map_name end |
#page_num ⇒ Object (readonly)
Returns the value of attribute page_num.
33 34 35 |
# File 'lib/wolftrans/context.rb', line 33 def page_num @page_num end |
Class Method Details
.from_data(map_name, event, page, cmd_index, command) ⇒ Object
60 61 62 |
# File 'lib/wolftrans/context.rb', line 60 def self.from_data(map_name, event, page, cmd_index, command) MapEvent.new(map_name, event.id, page.id + 1, cmd_index + 1, command.class.name.split('::').last) end |
.from_string(path) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/wolftrans/context.rb', line 64 def self.from_string(path) map_name, events_str, event_num, pages_str, page_num, line_num, command_name = path if events_str != 'events' || pages_str != 'pages' raise "unexpected path element in MPS context line" end MapEvent.new(map_name, event_num.to_i, page_num.to_i, line_num.to_i, command_name) end |
Instance Method Details
#eql?(other) ⇒ Boolean
45 46 47 48 49 50 |
# File 'lib/wolftrans/context.rb', line 45 def eql?(other) super && @map_name == other.map_name && @event_num == other.event_num && @page_num == other.page_num end |
#hash ⇒ Object
52 53 54 |
# File 'lib/wolftrans/context.rb', line 52 def hash [@map_name, @event_num, @page_num].hash end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/wolftrans/context.rb', line 56 def to_s "MPS:#{@map_name}/events/#{@event_num}/pages/#{@page_num}/#{@line_num}/#{@command_name}" end |