Class: Spider::DocType
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Instance Method Summary collapse
- #html? ⇒ Boolean
-
#initialize(type_or_str) ⇒ DocType
constructor
A new instance of DocType.
- #parse(str) ⇒ Object
- #strict? ⇒ Boolean
- #xhtml? ⇒ Boolean
Constructor Details
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
980 981 982 |
# File 'lib/spiderfw/templates/template.rb', line 980 def type @type end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
980 981 982 |
# File 'lib/spiderfw/templates/template.rb', line 980 def variant @variant end |
Instance Method Details
#html? ⇒ Boolean
1005 1006 1007 |
# File 'lib/spiderfw/templates/template.rb', line 1005 def html? @type == :html4 || @type == :html5 end |
#parse(str) ⇒ Object
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 |
# File 'lib/spiderfw/templates/template.rb', line 990 def parse(str) if str =~ /DOCTYPE HTML PUBLIC.+\sHTML/i @type = :html4 elsif str =~ /DOCTYPE HTML PUBLIC.+\sXHTML/i @type = :xhtml elsif str.downcase == '<!doctype html>' @type = :html5 end if str =~ /strict/i @variant = :strict elsif str =~ /transitional/i @variant = :transitional end end |
#strict? ⇒ Boolean
1013 1014 1015 |
# File 'lib/spiderfw/templates/template.rb', line 1013 def strict? @variant == :strict end |
#xhtml? ⇒ Boolean
1009 1010 1011 |
# File 'lib/spiderfw/templates/template.rb', line 1009 def xhtml? @type == :xhtml end |