Class: Spunk::Origin

Inherits:
Object
  • Object
show all
Defined in:
lib/spunk/origin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix) ⇒ Origin

Returns a new instance of Origin.



5
6
7
# File 'lib/spunk/origin.rb', line 5

def initialize(prefix)
  @prefix = prefix
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.



3
4
5
# File 'lib/spunk/origin.rb', line 3

def prefix
  @prefix
end

Instance Method Details

#nicknameObject



9
10
11
# File 'lib/spunk/origin.rb', line 9

def nickname
  @prefix.to_s.split(/!/, 2)[0]
end

#to_sObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/spunk/origin.rb', line 13

def to_s
  case
  when nickname != ""
    nickname
  when @prefix
    @prefix
  else
    "-unknown-"
  end
end