Class: Sprinkles::Origin

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Origin) initialize(prefix)



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

def initialize(prefix)
  @prefix = prefix
end

Instance Attribute Details

- (Object) prefix

Returns the value of attribute prefix



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

def prefix
  @prefix
end

Instance Method Details

- (Object) nickname



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

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

- (Object) to_s



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

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