Class: Rayo::Config::Domain
- Inherits:
-
Object
- Object
- Rayo::Config::Domain
- Extended by:
- Forwardable
- Defined in:
- lib/rayo/config/domain.rb
Instance Attribute Summary collapse
-
#cache_dir ⇒ Object
Get cache directory for this domain.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #directory(content_type) ⇒ Object
-
#initialize(parent, name, exp) ⇒ Domain
constructor
A new instance of Domain.
- #matches?(host) ⇒ Boolean
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_dir ⇒ Object
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 |
#name ⇒ Object (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
18 19 20 |
# File 'lib/rayo/config/domain.rb', line 18 def matches?( host ) host =~ @exp end |