Module: IcodiCore::OptionHandling
- Included in:
- Icodi
- Defined in:
- lib/icodi/option_handling.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *_args, &_block) ⇒ Object
3
4
5
|
# File 'lib/icodi/option_handling.rb', line 3
def method_missing(method_name, *_args, &_block)
respond_to?(method_name) ? options[method_name] : super
end
|
Instance Method Details
#default_options ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/icodi/option_handling.rb', line 11
def default_options
{
template: :default,
pixels: 5,
density: 0.5,
stroke: 0.1,
background: '#fff',
color: random_color,
mirror: :x,
jitter: 0,
id: :icodi,
}
end
|
#mirror_both? ⇒ Boolean
43
44
45
|
# File 'lib/icodi/option_handling.rb', line 43
def mirror_both?
mirror == :both
end
|
#mirror_x? ⇒ Boolean
35
36
37
|
# File 'lib/icodi/option_handling.rb', line 35
def mirror_x?
[:x, :both].include? mirror
end
|
#mirror_y? ⇒ Boolean
39
40
41
|
# File 'lib/icodi/option_handling.rb', line 39
def mirror_y?
[:y, :both].include? mirror
end
|
#respond_to?(method_name, include_private = false) ⇒ Boolean
7
8
9
|
# File 'lib/icodi/option_handling.rb', line 7
def respond_to?(method_name, include_private = false)
options.has_key?(method_name) ? true : super
end
|
#size ⇒ Object
27
28
29
|
# File 'lib/icodi/option_handling.rb', line 27
def size
@size ||= pixels * 10
end
|
#style ⇒ Object
31
32
33
|
# File 'lib/icodi/option_handling.rb', line 31
def style
@style ||= { stroke: color, stroke_width: stroke }
end
|