Class: SparkleAppcast::Rss

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkle_appcast/rss.rb

Constant Summary collapse

REQUIRED_FILEDS =
[
  :url,
  :length,
  :version,
  :dsa_signature
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Rss

Returns a new instance of Rss.



15
16
17
18
19
20
21
22
# File 'lib/sparkle_appcast/rss.rb', line 15

def initialize(params)
  REQUIRED_FILEDS.each do |field|
    unless params[field]
      raise ArgumentError.new("Missing #{field} param")
    end
  end
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



13
14
15
# File 'lib/sparkle_appcast/rss.rb', line 13

def params
  @params
end

Instance Method Details

#to_sObject



24
25
26
27
28
29
30
31
# File 'lib/sparkle_appcast/rss.rb', line 24

def to_s
  StringIO.new.tap do |output|
    output << %(<?xml version="1.0" encoding="UTF-8"?>\n)
    formatter = REXML::Formatters::Pretty.new(2)
    formatter.compact = true
    formatter.write(document, output)
  end.string
end