Class: ResoTransport::MetadataCache
- Inherits:
-
Object
- Object
- ResoTransport::MetadataCache
- Defined in:
- lib/reso_transport/metadata_cache.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ MetadataCache
constructor
A new instance of MetadataCache.
- #read ⇒ Object
- #write(raw) ⇒ Object
Constructor Details
#initialize(name) ⇒ MetadataCache
Returns a new instance of MetadataCache.
5 6 7 |
# File 'lib/reso_transport/metadata_cache.rb', line 5 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/reso_transport/metadata_cache.rb', line 3 def name @name end |
Instance Method Details
#read ⇒ Object
9 10 11 12 13 |
# File 'lib/reso_transport/metadata_cache.rb', line 9 def read return nil if !File.exist?(name) || File.size(name).zero? File.new(name) end |
#write(raw) ⇒ Object
15 16 17 18 |
# File 'lib/reso_transport/metadata_cache.rb', line 15 def write(raw) File.open(name, 'w') { |f| f.write(raw.force_encoding('UTF-8')) } if raw.length.positive? File.new(name) end |