Class: GeoWorks::Derivatives::Config::RenderingConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_works/derivatives/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRenderingConfiguration

Returns a new instance of RenderingConfiguration.



21
22
23
# File 'lib/geo_works/derivatives/config.rb', line 21

def initialize
  @settings ||= File.exist?(config_file) ? YAML.load_file(config_file) : {}
end

Instance Attribute Details

#bg_colorObject



48
49
50
# File 'lib/geo_works/derivatives/config.rb', line 48

def bg_color
  @bg_color ||= settings.fetch('bg_color', '#ffffff00')
end

#fillObject



52
53
54
# File 'lib/geo_works/derivatives/config.rb', line 52

def fill
  @fill ||= settings.fetch('fill', '#e4e3ea')
end

#line_capObject



64
65
66
# File 'lib/geo_works/derivatives/config.rb', line 64

def line_cap
  @line_cap ||= settings.fetch('line_cap', 'square')
end

#line_joinObject



68
69
70
# File 'lib/geo_works/derivatives/config.rb', line 68

def line_join
  @line_join ||= settings.fetch('line_join', 'miter')
end

#radiusObject



72
73
74
# File 'lib/geo_works/derivatives/config.rb', line 72

def radius
  @radius ||= settings.fetch('radius', '2')
end

#settingsObject (readonly)

Returns the value of attribute settings.



12
13
14
# File 'lib/geo_works/derivatives/config.rb', line 12

def settings
  @settings
end

#strokeObject



56
57
58
# File 'lib/geo_works/derivatives/config.rb', line 56

def stroke
  @stroke ||= settings.fetch('stroke', '#483d8b')
end

#weightObject



60
61
62
# File 'lib/geo_works/derivatives/config.rb', line 60

def weight
  @weight ||= settings.fetch('weight', '0.3')
end

Instance Method Details

#config_fileObject



25
26
27
# File 'lib/geo_works/derivatives/config.rb', line 25

def config_file
  File.join(config_root_path, 'config/simpler_tiles.yml')
end

#config_root_pathObject



29
30
31
32
33
34
35
# File 'lib/geo_works/derivatives/config.rb', line 29

def config_root_path
  if defined?(Rails) && Rails.root
    Rails.root
  else
    Pathname.new(Dir.pwd)
  end
end

#to_hObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/geo_works/derivatives/config.rb', line 37

def to_h
  {
    'stroke' => stroke,
    'line-cap' => line_cap,
    'line-join' => line_join,
    'weight' => weight,
    'fill' => fill,
    'radius' => radius
  }
end