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.
1018 1019 1020 |
# File 'lib/spiderfw/templates/template.rb', line 1018 def type @type end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
1018 1019 1020 |
# File 'lib/spiderfw/templates/template.rb', line 1018 def variant @variant end |
Instance Method Details
#html? ⇒ Boolean
1043 1044 1045 |
# File 'lib/spiderfw/templates/template.rb', line 1043 def html? @type == :html4 || @type == :html5 end |
#parse(str) ⇒ Object
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'lib/spiderfw/templates/template.rb', line 1028 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
1051 1052 1053 |
# File 'lib/spiderfw/templates/template.rb', line 1051 def strict? @variant == :strict end |
#xhtml? ⇒ Boolean
1047 1048 1049 |
# File 'lib/spiderfw/templates/template.rb', line 1047 def xhtml? @type == :xhtml end |