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.
933 934 935 |
# File 'lib/spiderfw/templates/template.rb', line 933 def type @type end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
933 934 935 |
# File 'lib/spiderfw/templates/template.rb', line 933 def variant @variant end |
Instance Method Details
#html? ⇒ Boolean
958 959 960 |
# File 'lib/spiderfw/templates/template.rb', line 958 def html? @type == :html4 || @type == :html5 end |
#parse(str) ⇒ Object
943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
# File 'lib/spiderfw/templates/template.rb', line 943 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
966 967 968 |
# File 'lib/spiderfw/templates/template.rb', line 966 def strict? @variant == :strict end |
#xhtml? ⇒ Boolean
962 963 964 |
# File 'lib/spiderfw/templates/template.rb', line 962 def xhtml? @type == :xhtml end |