Class: GitAuth::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/gitauth/message.rb

Constant Summary collapse

TEMPLATES =
YAML.load_file(BASE_DIR.join("resources", "messages.yml"))

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name, variables = {}) ⇒ Message

Returns a new instance of Message.



28
29
30
31
32
33
34
# File 'lib/gitauth/message.rb', line 28

def initialize(type, name, variables = {})
  @type      = type
  @name      = name
  @variables = {}
  variables.each_pair { |k,v| @variables[k.to_s] = v }
  auto_set_message!
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



26
27
28
# File 'lib/gitauth/message.rb', line 26

def message
  @message
end

#nameObject

Returns the value of attribute name.



26
27
28
# File 'lib/gitauth/message.rb', line 26

def name
  @name
end

#typeObject

Returns the value of attribute type.



26
27
28
# File 'lib/gitauth/message.rb', line 26

def type
  @type
end

#variablesObject

Returns the value of attribute variables.



26
27
28
# File 'lib/gitauth/message.rb', line 26

def variables
  @variables
end

Class Method Details

.error(name = :unknown) ⇒ Object

Handy accessor / generate methods for a given error code.



48
49
50
# File 'lib/gitauth/message.rb', line 48

def error(name = :unknown)
  new(:error, name)
end

.notice(name = :unknown) ⇒ Object



52
53
54
# File 'lib/gitauth/message.rb', line 52

def notice(name = :unknown)
  new(:notice, name)
end

.warning(name = :unknown) ⇒ Object



56
57
58
# File 'lib/gitauth/message.rb', line 56

def warning(name = :unknown)
  new(:warning, name)
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/gitauth/message.rb', line 40

def error?
  @type.to_sym == :error
end

#success?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/gitauth/message.rb', line 36

def success?
  @type.to_sym == :notice
end