Class: Stylesheet::Location
- Inherits:
-
Object
- Object
- Stylesheet::Location
- Defined in:
- lib/stylesheet/location.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#host ⇒ Object
(also: #hostname)
Returns the value of attribute host.
-
#href ⇒ Object
(also: #to_s)
Returns the value of attribute href.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#pathname ⇒ Object
Returns the value of attribute pathname.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#search ⇒ Object
Returns the value of attribute search.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #expand_paths_from_parent ⇒ Object
- #init_from_uri ⇒ Object
-
#initialize(url, parent = nil) ⇒ Location
constructor
A new instance of Location.
- #valid? ⇒ Boolean
Constructor Details
#initialize(url, parent = nil) ⇒ Location
Returns a new instance of Location.
9 10 11 12 13 14 15 16 |
# File 'lib/stylesheet/location.rb', line 9 def initialize(url, parent = nil) @uri = parse_uri(url) @host = uri.host @parent = parent self.init_from_uri self. end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
4 5 6 |
# File 'lib/stylesheet/location.rb', line 4 def hash @hash end |
#host ⇒ Object Also known as: hostname
Returns the value of attribute host.
3 4 5 |
# File 'lib/stylesheet/location.rb', line 3 def host @host end |
#href ⇒ Object Also known as: to_s
Returns the value of attribute href.
3 4 5 |
# File 'lib/stylesheet/location.rb', line 3 def href @href end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/stylesheet/location.rb', line 4 def parent @parent end |
#pathname ⇒ Object
Returns the value of attribute pathname.
4 5 6 |
# File 'lib/stylesheet/location.rb', line 4 def pathname @pathname end |
#port ⇒ Object
Returns the value of attribute port.
4 5 6 |
# File 'lib/stylesheet/location.rb', line 4 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
4 5 6 |
# File 'lib/stylesheet/location.rb', line 4 def protocol @protocol end |
#search ⇒ Object
Returns the value of attribute search.
4 5 6 |
# File 'lib/stylesheet/location.rb', line 4 def search @search end |
#uri ⇒ Object
Returns the value of attribute uri.
3 4 5 |
# File 'lib/stylesheet/location.rb', line 3 def uri @uri end |
Instance Method Details
#expand_paths_from_parent ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/stylesheet/location.rb', line 53 def return if valid_protocol? return unless parent self.pathname = URI.join(parent.to_s, uri.path).path self.protocol = parent.protocol self.host = parent.host end |
#init_from_uri ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/stylesheet/location.rb', line 18 def init_from_uri self.protocol = uri.scheme self.pathname = uri.path self.port = uri.port self.search = uri.query self.hash = uri.fragment end |
#valid? ⇒ Boolean
49 50 51 |
# File 'lib/stylesheet/location.rb', line 49 def valid? !!(valid_protocol? && valid_host?) end |