Module: Aqua::FileInitializations
Instance Method Summary collapse
- #content_length ⇒ Object
- #content_type ⇒ Object
- #filename ⇒ Object
- #to_aqua(opts = Aqua::Translator::Opts.new) ⇒ Object
- #to_aqua_class ⇒ Object
Instance Method Details
#content_length ⇒ Object
272 273 274 275 276 277 278 279 |
# File 'lib/aqua/object/initializers.rb', line 272 def content_length if len = stat.size rat = Aqua::Translator.pack_object( len ) rat.pack else '' end end |
#content_type ⇒ Object
281 282 283 284 |
# File 'lib/aqua/object/initializers.rb', line 281 def content_type mime = MIME::Types.type_for( self.path ) mime && mime.first ? mime.first.to_s : '' end |
#filename ⇒ Object
290 291 292 |
# File 'lib/aqua/object/initializers.rb', line 290 def filename path.match(/([^\/]*)\z/).to_s end |
#to_aqua(opts = Aqua::Translator::Opts.new) ⇒ Object
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/aqua/object/initializers.rb', line 252 def to_aqua( opts=Aqua::Translator::Opts.new ) rat = Aqua::Translator::Rat.new( { 'class' => to_aqua_class, 'init' => { 'id' => filename, 'methods' => { 'content_type' => content_type, 'content_length' => content_length } } }, {}, [self] ) ivar_rat = _pack_instance_vars( path ) rat.eat( ivar_rat ) if ivar_rat && ivar_rat.pack['ivars'] && !ivar_rat.pack['ivars'].empty? rat end |
#to_aqua_class ⇒ Object
286 287 288 |
# File 'lib/aqua/object/initializers.rb', line 286 def to_aqua_class 'Aqua::FileStub' end |