Class: Trifle::Stats::Nocturnal::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/trifle/stats/nocturnal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, range: nil, at: nil) ⇒ Key

Returns a new instance of Key.



10
11
12
13
14
15
# File 'lib/trifle/stats/nocturnal.rb', line 10

def initialize(key:, range: nil, at: nil)
  @prefix = nil
  @key = key
  @range = range
  @at = at
end

Instance Attribute Details

#atObject (readonly)

Returns the value of attribute at.



7
8
9
# File 'lib/trifle/stats/nocturnal.rb', line 7

def at
  @at
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/trifle/stats/nocturnal.rb', line 7

def key
  @key
end

#prefixObject

Returns the value of attribute prefix.



8
9
10
# File 'lib/trifle/stats/nocturnal.rb', line 8

def prefix
  @prefix
end

#rangeObject (readonly)

Returns the value of attribute range.



7
8
9
# File 'lib/trifle/stats/nocturnal.rb', line 7

def range
  @range
end

Instance Method Details

#identifier(separator) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/trifle/stats/nocturnal.rb', line 21

def identifier(separator)
  if separator
    { key: join(separator) }
  else
    { key: key, range: range, at: at }.compact
  end
end

#join(separator) ⇒ Object



17
18
19
# File 'lib/trifle/stats/nocturnal.rb', line 17

def join(separator)
  [prefix, key, range, at&.to_i].compact.join(separator)
end