Class: Spotlight::MDItem
- Inherits:
-
Object
show all
- Defined in:
- lib/spotlight.rb
Defined Under Namespace
Classes: InvalidAttributeValueTypeError
Constant Summary
collapse
- VALID_ATTRIBUTE_VALUE_TYPE =
[String, Time, Fixnum, Bignum, Float, Array, NilClass, TrueClass, FalseClass]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ MDItem
Returns a new instance of MDItem.
17
18
19
20
|
# File 'lib/spotlight.rb', line 17
def initialize(path)
raise ArgumentError, 'Path is nil' if path.nil?
@path = path
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
16
17
18
|
# File 'lib/spotlight.rb', line 16
def path
@path
end
|
Instance Method Details
#==(obj) ⇒ Object
37
38
39
|
# File 'lib/spotlight.rb', line 37
def ==(obj)
obj.is_a?(MDItem) && @path == obj.path
end
|
#[](attr_name) ⇒ Object
27
28
29
|
# File 'lib/spotlight.rb', line 27
def [](attr_name)
Intern.get_attribute(@path, attr_name)
end
|
#[]=(attr_name, attr_value) ⇒ Object
30
31
32
33
|
# File 'lib/spotlight.rb', line 30
def []=(attr_name, attr_value)
validate(attr_value)
Intern.set_attribute(@path, attr_name, attr_value)
end
|
#attributes ⇒ Object
21
22
23
|
# File 'lib/spotlight.rb', line 21
def attributes
Intern.attributes(@path)
end
|
#attributes=(attributes) ⇒ Object
24
25
26
|
# File 'lib/spotlight.rb', line 24
def attributes=(attributes)
Intern.set_attributes(@path, attributes)
end
|
#reload ⇒ Object
34
35
36
|
# File 'lib/spotlight.rb', line 34
def reload
self
end
|
#validate(value) ⇒ Object