Class: Figure::Figurine

Inherits:
Hash
  • Object
show all
Includes:
DepartmentStore, Store, Singleton
Defined in:
lib/figure/figurine.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Store

#[]=, #default, #default_store, #has_key?, #merge!

Constructor Details

#initializeFigurine

Returns a new instance of Figurine.



30
31
32
33
34
35
36
37
38
# File 'lib/figure/figurine.rb', line 30

def initialize
  h = self.class.with_data || {}

  (h.delete(:default) || h.delete(:gaston)).tap do |data|
    self[:default] = new_store :default, data, self.class if data
  end

  merge! h
end

Class Attribute Details

.labelObject

Returns the value of attribute label.



14
15
16
# File 'lib/figure/figurine.rb', line 14

def label
  @label
end

.with_dataObject

Returns the value of attribute with_data.



14
15
16
# File 'lib/figure/figurine.rb', line 14

def with_data
  @with_data
end

Class Method Details

.default_typeObject



16
17
18
# File 'lib/figure/figurine.rb', line 16

def default_type
  @default_type ||= label.include? 'Default'
end

.patternObject



20
21
22
# File 'lib/figure/figurine.rb', line 20

def pattern
  @pattern ||= label.gsub 'Default', '[^:]+'
end

.with(data) ⇒ Object



24
25
26
# File 'lib/figure/figurine.rb', line 24

def with(data)
  self.tap { |s| s.with_data = data }
end