Class: MyMediaCard
- Inherits:
-
MyMediaKvx
- Object
- MyMediaKvx
- MyMediaCard
- Defined in:
- lib/mymedia-card.rb
Instance Attribute Summary collapse
-
#txt_filepath ⇒ Object
readonly
Returns the value of attribute txt_filepath.
Instance Method Summary collapse
- #create_metadata_file ⇒ Object
-
#initialize(opt = {}, public_type: 'kvx', media_type: public_type, config: nil, ext: 'txt') ⇒ MyMediaCard
constructor
A new instance of MyMediaCard.
Constructor Details
#initialize(opt = {}, public_type: 'kvx', media_type: public_type, config: nil, ext: 'txt') ⇒ MyMediaCard
Returns a new instance of MyMediaCard.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mymedia-card.rb', line 12 def initialize(opt={}, public_type: 'kvx', media_type: public_type, config: nil, ext: 'txt') super(media_type: media_type, public_type: public_type, config: config, ext: ext) @prefix = 'meta' @txt_filepath = File.join(@media_src, \ Time.now.strftime('meta%d%m%yT%H%M') + '.txt' ) end |
Instance Attribute Details
#txt_filepath ⇒ Object (readonly)
Returns the value of attribute txt_filepath.
10 11 12 |
# File 'lib/mymedia-card.rb', line 10 def txt_filepath @txt_filepath end |
Instance Method Details
#create_metadata_file ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mymedia-card.rb', line 23 def raise "MyMediaCard: ext: must be supplied at initialize()" unless @ext dir = DirToXML.new(@media_src) raw_s = dir.select_by_ext(@ext).sort_by_lastmodified.last[:name] s,ext = raw_s.split(/(?=\.\w+$)/) ext = '' if ext == '.dir' raw_name, = s.split(/--/,2) = ? .split(/--/) : [] desc = raw_name.gsub(/-/,' ') desc.capitalize! unless desc[0] == desc[0].upcase filename = raw_name.downcase + ext static_path = "%s/%s/%s" % [@public_type, \ Time.now.strftime('%Y/%b/%d').downcase, filename] raw_static_destination = "/r/%s" % [static_path] summary = {title: desc, tags: .join(' ')} body = {file: raw_static_destination} kvx = Kvx.new({summary: summary, body: body}, \ attributes: {type: @media_type}) Dir.chdir @media_src File.write @txt_filepath, kvx.to_s FileUtils.mv raw_s, filename end |