Class: WebStruct::Page::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/webstruct/page/content.rb

Overview

Decodes bytes from Content-Type charset, then parses the body by MIME bucket.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, content_type, type) ⇒ Content

Returns a new instance of Content.

Parameters:

  • raw (String)
  • content_type (String)
  • type (Symbol)


19
20
21
22
23
24
# File 'lib/webstruct/page/content.rb', line 19

def initialize(raw, content_type, type)
  @raw = raw
  charset = Http::ContentType.charset(content_type)
  utf8 = Http::ContentType.decode_to_utf8(raw, charset)
  @parsed = parse(utf8, type)
end

Instance Attribute Details

#parsedObject (readonly)

Returns the value of attribute parsed.



14
15
16
# File 'lib/webstruct/page/content.rb', line 14

def parsed
  @parsed
end

#rawObject (readonly)

Returns the value of attribute raw.



14
15
16
# File 'lib/webstruct/page/content.rb', line 14

def raw
  @raw
end