Class: Nexpose::File
Overview
File or directory on an asset.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
File attributes.
-
#directory ⇒ Object
readonly
Whether the file is a directory.
-
#name ⇒ Object
readonly
Name of the file.
-
#size ⇒ Object
readonly
Size of the file.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #directory? ⇒ Boolean
- #eql?(other) ⇒ Boolean
-
#initialize(name = nil, size = 0, directory = false, attributes = []) ⇒ File
constructor
A new instance of File.
- #to_h ⇒ Object
Methods inherited from APIObject
Constructor Details
#initialize(name = nil, size = 0, directory = false, attributes = []) ⇒ File
Returns a new instance of File.
232 233 234 |
# File 'lib/nexpose/asset.rb', line 232 def initialize(name = nil, size = 0, directory = false, attributes = []) @name, @size, @directory, @attributes = name, size, directory, attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
File attributes.
228 229 230 |
# File 'lib/nexpose/asset.rb', line 228 def attributes @attributes end |
#directory ⇒ Object (readonly)
Whether the file is a directory.
230 231 232 |
# File 'lib/nexpose/asset.rb', line 230 def directory @directory end |
#name ⇒ Object (readonly)
Name of the file.
224 225 226 |
# File 'lib/nexpose/asset.rb', line 224 def name @name end |
#size ⇒ Object (readonly)
Size of the file.
226 227 228 |
# File 'lib/nexpose/asset.rb', line 226 def size @size end |
Instance Method Details
#<=>(other) ⇒ Object
247 248 249 250 251 252 253 254 255 |
# File 'lib/nexpose/asset.rb', line 247 def <=>(other) c = name <=> other.name return c unless c == 0 c = size <=> other.size return c unless c == 0 c = directory <=> other.directory return c unless c == 0 attributes <=> other.attributes end |
#==(other) ⇒ Object
257 258 259 |
# File 'lib/nexpose/asset.rb', line 257 def ==(other) eql?(other) end |
#directory? ⇒ Boolean
236 237 238 |
# File 'lib/nexpose/asset.rb', line 236 def directory? directory end |
#eql?(other) ⇒ Boolean
261 262 263 |
# File 'lib/nexpose/asset.rb', line 261 def eql?(other) name.eql?(other.name) && size.eql?(other.size) && directory.eql?(other.directory) && attributes.eql?(other.attributes) end |
#to_h ⇒ Object
240 241 242 243 244 245 |
# File 'lib/nexpose/asset.rb', line 240 def to_h { name: name, size: size, directory: directory, attributes: Attributes.to_hash(attributes) } end |