Class: Rayo::Config::Domain

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rayo/config/domain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, name, exp) ⇒ Domain

Returns a new instance of Domain.



12
13
14
15
16
# File 'lib/rayo/config/domain.rb', line 12

def initialize( parent, name, exp )
  @parent = parent
  @name = name
  @exp = exp || Regexp.new( "^#{Regexp.quote( name )}\.?$" )
end

Instance Attribute Details

#cache_dirObject

Get cache directory for this domain. If it was not set explicitly it’ll be global cache_dir with domain name appended



31
32
33
# File 'lib/rayo/config/domain.rb', line 31

def cache_dir
  @cache_dir || @parent.cache_dir && File.join( @parent.cache_dir, @name )
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/rayo/config/domain.rb', line 9

def name
  @name
end

Instance Method Details

#directory(content_type) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rayo/config/domain.rb', line 22

def directory( content_type )
  if content_type == :pages
    File.join( @parent.directory( content_type ), @name )
  else
    @parent.directory( content_type )
  end
end

#matches?(host) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rayo/config/domain.rb', line 18

def matches?( host )
  host =~ @exp
end