Module: IcodiCore::Options

Included in:
Icodi
Defined in:
lib/icodi/options.rb

Instance Method Summary collapse

Instance Method Details

#backgroundObject



16
17
18
# File 'lib/icodi/options.rb', line 16

def background
  options[:background]
end

#colorObject



20
21
22
# File 'lib/icodi/options.rb', line 20

def color
  options[:color]
end

#default_optionsObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/icodi/options.rb', line 3

def default_options
  {
    pixels:     5,
    density:    0.5,
    stroke:     0.1,
    background: '#fff',
    color:      random_color,
    mirror:     :x,
    jitter:     0,
    id:         :icodi,
  }
end

#densityObject



24
25
26
# File 'lib/icodi/options.rb', line 24

def density
  options[:density]
end

#idObject



28
29
30
# File 'lib/icodi/options.rb', line 28

def id
  options[:id]
end

#jitterObject



32
33
34
# File 'lib/icodi/options.rb', line 32

def jitter
  options[:jitter]
end

#mirrorObject



36
37
38
# File 'lib/icodi/options.rb', line 36

def mirror
  options[:mirror]
end

#mirror_both?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/icodi/options.rb', line 48

def mirror_both?
  mirror == :both
end

#mirror_x?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/icodi/options.rb', line 40

def mirror_x?
  %i[x both].include? mirror
end

#mirror_y?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/icodi/options.rb', line 44

def mirror_y?
  %i[y both].include? mirror
end

#pixelsObject



52
53
54
# File 'lib/icodi/options.rb', line 52

def pixels
  options[:pixels]
end

#sizeObject



56
57
58
# File 'lib/icodi/options.rb', line 56

def size
  @size ||= pixels * 10
end

#strokeObject



60
61
62
# File 'lib/icodi/options.rb', line 60

def stroke
  options[:stroke]
end

#styleObject



64
65
66
# File 'lib/icodi/options.rb', line 64

def style
  @style ||= { stroke: color, stroke_width: stroke }
end