Class: Agio::XMLDecl

Inherits:
Object
  • Object
show all
Defined in:
lib/agio/data.rb

Overview

A simple wrapper around the contents of an XML declaration in an XHTML document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ XMLDecl

Returns a new instance of XMLDecl.



47
48
49
50
51
# File 'lib/agio/data.rb', line 47

def initialize(options = {})
  @version = options[:version]
  @encoding = options[:encoding]
  @standalone = options[:standalone]
end

Instance Attribute Details

#encodingObject (readonly)

Returns the value of attribute encoding.



53
54
55
# File 'lib/agio/data.rb', line 53

def encoding
  @encoding
end

#standaloneObject (readonly)

Returns the value of attribute standalone.



53
54
55
# File 'lib/agio/data.rb', line 53

def standalone
  @standalone
end

#versionObject (readonly)

Returns the value of attribute version.



53
54
55
# File 'lib/agio/data.rb', line 53

def version
  @version
end

Instance Method Details

#==(other) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/agio/data.rb', line 76

def ==(other)
  case other
  when String
    to_s == other
  when Array
    to_a == other
  when Agio::XMLDecl
    to_s == other.to_s
  else
    false
  end
end

#inspectObject



68
69
70
# File 'lib/agio/data.rb', line 68

def inspect
  %Q(#<#{self.class} '#{to_s}'>)
end

#to_aObject



55
56
57
# File 'lib/agio/data.rb', line 55

def to_a
  [ version, encoding, standalone ]
end

#to_sObject



59
60
61
62
63
64
65
66
# File 'lib/agio/data.rb', line 59

def to_s
  s = %Q(<?xml )
  s += %Q(version="#{version}" ) unless version.nil?
  s += %Q(encoding="#{encoding}" ) unless encoding.nil?
  s += %Q(standalone="#{!!standalone}" ) unless standalone.nil?
  s += "?>"
  s
end

#to_strObject



72
73
74
# File 'lib/agio/data.rb', line 72

def to_str
  to_s
end