Class: SVNx::Action

Inherits:
Object
  • Object
show all
Includes:
Comparable, Logue::Loggable
Defined in:
lib/svnx/base/action.rb

Constant Summary collapse

STATUS_TO_TYPE =
Hash.new
STATUS_TO_ACTION =
Hash.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, char) ⇒ Action

Returns a new instance of Action.



16
17
18
19
# File 'lib/svnx/base/action.rb', line 16

def initialize type, char
  @type = type
  @char = char
end

Instance Attribute Details

#charObject (readonly)

Returns the value of attribute char.



11
12
13
# File 'lib/svnx/base/action.rb', line 11

def char
  @char
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/svnx/base/action.rb', line 10

def type
  @type
end

Class Method Details

.add_type(str, char) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/svnx/base/action.rb', line 36

def add_type str, char
  sym = str.to_sym
  STATUS_TO_TYPE[sym] = sym
  action = SVNx::Action.new sym, char
  SVNx::Action.const_set str.upcase, action
  [ sym, str, char ].each do |key|
    STATUS_TO_ACTION[key] = action
  end
end

.new(arg, char = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/svnx/base/action.rb', line 24

def new arg, char = nil
  if arg.kind_of? Action
    arg
  elsif act = STATUS_TO_ACTION[arg]
    act
  else
    type = STATUS_TO_TYPE[arg]
    raise "no such action: #{arg.inspect}" unless type
    STATUS_TO_ACTION[arg] = orig_new type, char
  end
end

.orig_newObject



22
# File 'lib/svnx/base/action.rb', line 22

alias_method :orig_new, :new

Instance Method Details

#<=>(other) ⇒ Object



47
48
49
# File 'lib/svnx/base/action.rb', line 47

def <=> other
  @type <=> other.type
end

#to_sObject



51
52
53
# File 'lib/svnx/base/action.rb', line 51

def to_s
  @type.to_s
end