Class: YandexClient::Dav::PropFindResponse

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/yandex_client/dav/prop_find_response.rb

Defined Under Namespace

Classes: Item

Constant Summary collapse

SUCCESS_STATUS =
'HTTP/1.1 200 OK'

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ PropFindResponse

Returns a new instance of PropFindResponse.



49
50
51
52
53
54
# File 'lib/yandex_client/dav/prop_find_response.rb', line 49

def initialize(xml)
  @doc = Ox.load(
    xml.dup.force_encoding('UTF-8'),
    mode: :hash
  )
end

Instance Method Details

#eachObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/yandex_client/dav/prop_find_response.rb', line 56

def each
  @doc[:'d:multistatus'].each do |node|
    next if (response = node[:'d:response']).nil?

    name = CGI.unescape(response.fetch(:'d:href'))
    node_data = response.fetch(:'d:propstat')

    raise ParseError unless node_data.fetch(:'d:status') == SUCCESS_STATUS

    yield Item.new(name, node_data.fetch(:'d:prop'))
  end
end