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

#[]=, #complete_defaults, #default, #figures, #has_key?, #merge!

Constructor Details

#initializeFigurine

Returns a new instance of Figurine.



34
35
36
37
38
39
40
41
# File 'lib/figure/figurine.rb', line 34

def initialize
  h = self.class.with_data || {}
  default_h, @forward = find_default h

  self[:default] = new_store :default, default_h, self.class if default_h
  merge! h
  complete_defaults
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(options) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/figure/figurine.rb', line 24

def with(options)
  tap do |f|
    options.each do |k, v|
      f.send "with_#{k}=", v
    end
  end
end

Instance Method Details

#can_forward?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/figure/figurine.rb', line 47

def can_forward?
  !!@forward
end

#forward!Object



43
44
45
# File 'lib/figure/figurine.rb', line 43

def forward!
  self[ has_key? forward_response ]
end