Class: StyleSheet

Inherits:
Object
  • Object
show all
Defined in:
lib/hubdown/style_sheet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/hubdown/style_sheet.rb', line 6

def content
  @content
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/hubdown/style_sheet.rb', line 4

def name
  @name
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/hubdown/style_sheet.rb', line 5

def url
  @url
end

Instance Method Details

#download_contentObject



21
22
23
# File 'lib/hubdown/style_sheet.rb', line 21

def download_content
  @content ||= open("#{@url}/#{name}").read
end

#from_tag(tag) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/hubdown/style_sheet.rb', line 9

def from_tag tag
  matcher = /href=['|"](([\w:.\/])*)\/([\w|-]+.css)/.match( tag.to_s )
  if matcher
    @url = matcher.captures[0]
    @name = matcher.captures[2]
  end
end

#to_tagObject



17
18
19
# File 'lib/hubdown/style_sheet.rb', line 17

def to_tag
  "<link href=\"#{url}/#{name}\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\">"
end