Class: GeoPattern::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_pattern/pattern.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(svg_image = SvgImage.new) ⇒ Pattern

Returns a new instance of Pattern.



13
14
15
# File 'lib/geo_pattern/pattern.rb', line 13

def initialize(svg_image = SvgImage.new)
  @svg_image = svg_image
end

Instance Attribute Details

#backgroundObject

Returns the value of attribute background.



11
12
13
# File 'lib/geo_pattern/pattern.rb', line 11

def background
  @background
end

#heightObject

Returns the value of attribute height.



11
12
13
# File 'lib/geo_pattern/pattern.rb', line 11

def height
  @height
end

#structureObject

Returns the value of attribute structure.



11
12
13
# File 'lib/geo_pattern/pattern.rb', line 11

def structure
  @structure
end

#widthObject

Returns the value of attribute width.



11
12
13
# File 'lib/geo_pattern/pattern.rb', line 11

def width
  @width
end

Instance Method Details

#base64_stringObject

Deprecated.

See Also:



68
69
70
71
72
# File 'lib/geo_pattern/pattern.rb', line 68

def base64_string
  warn 'Using "#base64_string" is deprecated as of 1.3.1. Please use "#to_base64" instead.'

  to_base64
end

#generate_me(generator) ⇒ Object

Generate things for the pattern

Parameters:

  • generator (#generate)

    The generator which should do things with this pattern - e.g. adding background or a structure



30
31
32
# File 'lib/geo_pattern/pattern.rb', line 30

def generate_me(generator)
  generator.generate self
end

#include?(string) ⇒ Boolean

Check if string is included in pattern

Parameters:

  • string (String)

    The checked string

Returns:

  • (Boolean)


21
22
23
# File 'lib/geo_pattern/pattern.rb', line 21

def include?(string)
  image.include?(string)
end

#svg_stringObject

Deprecated.

See Also:



60
61
62
63
64
# File 'lib/geo_pattern/pattern.rb', line 60

def svg_string
  warn 'Using "#svg_string" is deprecated as of 1.3.1. Please use "#to_svg" instead.'

  to_svg
end

#to_base64Object

Convert to base64



41
42
43
# File 'lib/geo_pattern/pattern.rb', line 41

def to_base64
  Base64.strict_encode64(to_svg)
end

#to_data_uriObject

Convert to data uri



46
47
48
# File 'lib/geo_pattern/pattern.rb', line 46

def to_data_uri
  "url(data:image/svg+xml;base64,#{to_base64});"
end

#to_svgObject Also known as: to_s

Convert pattern to svg



35
36
37
# File 'lib/geo_pattern/pattern.rb', line 35

def to_svg
  image.to_s
end

#uri_imageObject

Deprecated.

See Also:



52
53
54
55
56
# File 'lib/geo_pattern/pattern.rb', line 52

def uri_image
  warn 'Using "#uri_image" is deprecated as of 1.3.1. Please use "#to_data_uri" instead.'

  to_data_uri
end