Sha256: 8c8e907b73293d3d440e7081c95bcffbc5939d5f5a8fdd4b7f557ac342b6dfa5

Contents?: true

Size: 491 Bytes

Versions: 3

Compression:

Stored size: 491 Bytes

Contents

require 'open-uri'

class StyleSheet
  attr_accessor :name
  attr_accessor :url
  attr_accessor :content


  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

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

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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hubdown-0.0.15 lib/hubdown/style_sheet.rb
hubdown-0.0.14 lib/hubdown/style_sheet.rb
hubdown-0.0.13 lib/hubdown/style_sheet.rb