Class: NVX::SDS::SearchItem

Inherits:
Object
  • Object
show all
Defined in:
lib/nvx/sds/searchitem.rb

Overview

Overview

The SearchItem object is used for all search results. The object is returned from calls to either

session.SearchFileSystem
session.SearchMetadata
session.SearchTags

Usage

session = Session.new("APP-KEY", "USERNAME", "APP NAME", "PASSWORD")
search_results_array = session.SearchFileSystem("Beatles*", "Image")

search_results_array.each do |search_item|
    print search_item.name
end

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ SearchItem

Takes a single search item in an xml string fragment and populates the object with the values.



37
38
39
40
41
42
43
44
45
46
# File 'lib/nvx/sds/searchitem.rb', line 37

def initialize(xml)
    doc = REXML::Document.new(xml)
    
    @name = (text = doc.root.elements["//Item/ItemName"].get_text and text.value)
    @path = (text = doc.root.elements["//Item/ItemPath"].get_text and text.value)
    @created_date = (text = doc.root.elements["//Item/CreatedDate"].get_text and text.value)
    @size_bytes = (text = doc.root.elements["//Item/SizeBytes"].get_text and text.value)
    @file_type = (text = doc.root.elements["//Item/FileType"].get_text and text.value)
    @is_file = (text = doc.root.elements["//Item/IsFile"].get_text and text.value) == "true"
end

Instance Method Details

#created_dateObject

Date created or uploaded.



59
60
61
# File 'lib/nvx/sds/searchitem.rb', line 59

def created_date
    @created_date
end

#file_typeObject

The file type



69
70
71
# File 'lib/nvx/sds/searchitem.rb', line 69

def file_type
    @file_type
end

#is_fileObject

If the result is a file or a folder.



74
75
76
# File 'lib/nvx/sds/searchitem.rb', line 74

def is_file
    @is_file
end

#nameObject

The file / folder name.



49
50
51
# File 'lib/nvx/sds/searchitem.rb', line 49

def name
    @name
end

#pathObject

The full path.



54
55
56
# File 'lib/nvx/sds/searchitem.rb', line 54

def path
    @path
end

#size_bytesObject

The size



64
65
66
# File 'lib/nvx/sds/searchitem.rb', line 64

def size_bytes
    @size_bytes
end