Class: RSSFS

Inherits:
Object
  • Object
show all
Defined in:
ext/dokan-ruby-0.1.5.1229/sample/rssfs.rb

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ RSSFS

Returns a new instance of RSSFS.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'ext/dokan-ruby-0.1.5.1229/sample/rssfs.rb', line 5

def initialize table
  @files = Hash.new
  @files["/"] = Array.new
  table.each do |k,v|
    rss =  RSS::Parser.parse(v)
    rss.output_encoding = "Shift_JIS"
    @files["/"].push k
    @files["/#{k}"] = Array.new
    rss.items.each do |item|
      @files["/#{k}"].push "#{item.title}.txt"
      @files["/#{k}/#{item.title}.txt"] = item.description
    end
  end
end

Instance Method Details

#contents(path) ⇒ Object



28
29
30
31
32
33
34
# File 'ext/dokan-ruby-0.1.5.1229/sample/rssfs.rb', line 28

def contents path
  if @files[path.sub(/(.+)\/$/, '\1')].instance_of? Array
    @files[path.sub(/(.+)\/$/, '\1')]
  else
    false
  end
end

#directory?(path) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'ext/dokan-ruby-0.1.5.1229/sample/rssfs.rb', line 24

def directory? path
  @files[path.sub(/(.+)\/$/, '\1')].instance_of? Array
end

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'ext/dokan-ruby-0.1.5.1229/sample/rssfs.rb', line 20

def file? path
  @files[path].instance_of? String
end

#read_file(path) ⇒ Object



36
37
38
# File 'ext/dokan-ruby-0.1.5.1229/sample/rssfs.rb', line 36

def read_file path
  @files[path]
end

#size(path) ⇒ Object



40
41
42
43
44
45
46
# File 'ext/dokan-ruby-0.1.5.1229/sample/rssfs.rb', line 40

def size path
  if @files[path].instance_of? String
    @files[path].size
  else
    0
  end
end