Class: WolfTrans::Context::CommonEvent

Inherits:
WolfTrans::Context show all
Defined in:
lib/wolftrans/context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_num, line_num, command_name) ⇒ CommonEvent

Returns a new instance of CommonEvent.



78
79
80
81
82
# File 'lib/wolftrans/context.rb', line 78

def initialize(event_num, line_num, command_name)
  @event_num = event_num
  @line_num = line_num
  @command_name = command_name
end

Instance Attribute Details

#command_nameObject (readonly)

Returns the value of attribute command_name.



76
77
78
# File 'lib/wolftrans/context.rb', line 76

def command_name
  @command_name
end

#event_numObject (readonly)

Returns the value of attribute event_num.



74
75
76
# File 'lib/wolftrans/context.rb', line 74

def event_num
  @event_num
end

#line_numObject (readonly)

Returns the value of attribute line_num.



75
76
77
# File 'lib/wolftrans/context.rb', line 75

def line_num
  @line_num
end

Class Method Details

.from_data(event, cmd_index, command) ⇒ Object



96
97
98
# File 'lib/wolftrans/context.rb', line 96

def self.from_data(event, cmd_index, command)
  CommonEvent.new(event.id, cmd_index + 1, command.class.name.split('::').last)
end

.from_string(path) ⇒ Object



100
101
102
103
# File 'lib/wolftrans/context.rb', line 100

def self.from_string(path)
  event_num, line_num, command_name = path
  CommonEvent.new(event_num.to_i, line_num.to_i, command_name)
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/wolftrans/context.rb', line 84

def eql?(other)
  super && @event_num == other.event_num
end

#hashObject



88
89
90
# File 'lib/wolftrans/context.rb', line 88

def hash
  @event_num.hash
end

#to_sObject



92
93
94
# File 'lib/wolftrans/context.rb', line 92

def to_s
  "COMMONEVENT:#{@event_num}/#{@line_num}/#{@command_name}"
end