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.
234 235 236 |
# File 'lib/nexpose/asset.rb', line 234 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.
230 231 232 |
# File 'lib/nexpose/asset.rb', line 230 def attributes @attributes end |
#directory ⇒ Object (readonly)
Whether the file is a directory.
232 233 234 |
# File 'lib/nexpose/asset.rb', line 232 def directory @directory end |
#name ⇒ Object (readonly)
Name of the file.
226 227 228 |
# File 'lib/nexpose/asset.rb', line 226 def name @name end |
#size ⇒ Object (readonly)
Size of the file.
228 229 230 |
# File 'lib/nexpose/asset.rb', line 228 def size @size end |
Instance Method Details
#<=>(other) ⇒ Object
249 250 251 252 253 254 255 256 257 |
# File 'lib/nexpose/asset.rb', line 249 def <=>(other) c = name <=> other.name return c unless c.zero? c = size <=> other.size return c unless c.zero? c = directory <=> other.directory return c unless c.zero? attributes <=> other.attributes end |
#==(other) ⇒ Object
259 260 261 |
# File 'lib/nexpose/asset.rb', line 259 def ==(other) eql?(other) end |
#directory? ⇒ Boolean
238 239 240 |
# File 'lib/nexpose/asset.rb', line 238 def directory? directory end |
#eql?(other) ⇒ Boolean
263 264 265 |
# File 'lib/nexpose/asset.rb', line 263 def eql?(other) name.eql?(other.name) && size.eql?(other.size) && directory.eql?(other.directory) && attributes.eql?(other.attributes) end |
#to_h ⇒ Object
242 243 244 245 246 247 |
# File 'lib/nexpose/asset.rb', line 242 def to_h { name: name, size: size, directory: directory, attributes: Attributes.to_hash(attributes) } end |