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.


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

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

Instance Attribute Details

#backgroundObject

Returns the value of attribute background.


9
10
11
# File 'lib/geo_pattern/pattern.rb', line 9

def background
  @background
end

#heightObject

Returns the value of attribute height.


9
10
11
# File 'lib/geo_pattern/pattern.rb', line 9

def height
  @height
end

#structureObject

Returns the value of attribute structure.


9
10
11
# File 'lib/geo_pattern/pattern.rb', line 9

def structure
  @structure
end

#widthObject

Returns the value of attribute width.


9
10
11
# File 'lib/geo_pattern/pattern.rb', line 9

def width
  @width
end

Instance Method Details

#base64_stringObject

Deprecated.

See Also:


66
67
68
69
70
# File 'lib/geo_pattern/pattern.rb', line 66

def base64_string
  $stderr.puts '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


28
29
30
# File 'lib/geo_pattern/pattern.rb', line 28

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)

19
20
21
# File 'lib/geo_pattern/pattern.rb', line 19

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

#svg_stringObject

Deprecated.

See Also:


58
59
60
61
62
# File 'lib/geo_pattern/pattern.rb', line 58

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

  to_svg
end

#to_base64Object

Convert to base64


39
40
41
# File 'lib/geo_pattern/pattern.rb', line 39

def to_base64
  Base64.strict_encode64(to_svg)
end

#to_data_uriObject

Convert to data uri


44
45
46
# File 'lib/geo_pattern/pattern.rb', line 44

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

#to_svgObject Also known as: to_s

Convert pattern to svg


33
34
35
# File 'lib/geo_pattern/pattern.rb', line 33

def to_svg
  image.to_s
end

#uri_imageObject

Deprecated.

See Also:


50
51
52
53
54
# File 'lib/geo_pattern/pattern.rb', line 50

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

  to_data_uri
end