Class: StaticConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/static_server/static_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir = nil) ⇒ StaticConfig

Returns a new instance of StaticConfig.



3
4
5
6
7
8
9
10
# File 'lib/static_server/static_config.rb', line 3

def initialize(base_dir = nil)
  @base_dir = base_dir
  @base_dir ||= 'public'

  @redirects = {}
  @forwards = {}
  @root = 'index.html'
end

Instance Attribute Details

#base_dir ⇒ Object (readonly)

Returns the value of attribute base_dir.



2
3
4
# File 'lib/static_server/static_config.rb', line 2

def base_dir
  @base_dir
end

#forwards ⇒ Object (readonly)

Returns the value of attribute forwards.



2
3
4
# File 'lib/static_server/static_config.rb', line 2

def forwards
  @forwards
end

#redirects ⇒ Object (readonly)

Returns the value of attribute redirects.



2
3
4
# File 'lib/static_server/static_config.rb', line 2

def redirects
  @redirects
end

Instance Method Details

#forward(opt) ⇒ Object



17
18
19
20
# File 'lib/static_server/static_config.rb', line 17

def forward(opt)
  validate_params(opt)
  @forwards.merge! opt
end

#redirect(opt) ⇒ Object



12
13
14
15
# File 'lib/static_server/static_config.rb', line 12

def redirect(opt)
  validate_params(opt)
  @redirects.merge! opt
end

#root(path = nil) ⇒ Object



22
23
24
25
# File 'lib/static_server/static_config.rb', line 22

def root(path = nil)
  @root = path if path
  @root
end