Class: Fusuma::Config::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/config/index.rb

Overview

index for config.yml

Defined Under Namespace

Classes: Key

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keys) ⇒ Index

Returns a new instance of Index.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fusuma/config/index.rb', line 8

def initialize(keys)
  @count = 0
  case keys
  when Array
    @keys = []
    @cache_key = keys.map do |key|
      key = Key.new(key) if !key.is_a? Key
      @keys << key
      key.symbol
    end.join(",").to_sym
  else
    key = Key.new(keys)
    @cache_key = key.symbol
    @keys = [key]
  end
end

Instance Attribute Details

#cache_keyObject (readonly)

Returns the value of attribute cache_key.



35
36
37
# File 'lib/fusuma/config/index.rb', line 35

def cache_key
  @cache_key
end

#keysObject (readonly)

Returns the value of attribute keys.



35
36
37
# File 'lib/fusuma/config/index.rb', line 35

def keys
  @keys
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
32
33
# File 'lib/fusuma/config/index.rb', line 29

def ==(other)
  return false unless other.is_a? Index

  cache_key == other.cache_key
end

#to_sObject



25
26
27
# File 'lib/fusuma/config/index.rb', line 25

def to_s
  @keys.map(&:inspect)
end