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



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

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

#from_tag(tag) ⇒ Object



9
10
11
12
13
14
15
16
# 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[1]
  end
end

#to_tagObject



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

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