Class: Ryodo::SuffixList

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ryodo/suffix_list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE) ⇒ SuffixList

Returns a new instance of SuffixList.



7
8
9
# File 'lib/ryodo/suffix_list.rb', line 7

def initialize(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE)
  load_file(suffix_file)
end

Instance Attribute Details

#suffix_dataObject (readonly) Also known as: list

Returns the value of attribute suffix_data.



5
6
7
# File 'lib/ryodo/suffix_list.rb', line 5

def suffix_data
  @suffix_data
end

Class Method Details

.instanceObject



39
40
41
# File 'lib/ryodo/suffix_list.rb', line 39

def instance
  @instance ||= new
end

.reload(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE) ⇒ Object

rubocop:enable Style/MethodName



35
36
37
# File 'lib/ryodo/suffix_list.rb', line 35

def reload(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE)
  instance.load_file(suffix_file) && true
end

.SuffixList(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE) ⇒ Object

rubocop:disable Style/MethodName



30
31
32
# File 'lib/ryodo/suffix_list.rb', line 30

def SuffixList(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE)
  instance(suffix_file)
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/ryodo/suffix_list.rb', line 22

def inspect
  "#<#{self.class} FILE:#{@suffix_file} ENTRIES:#{@suffix_data.size}>"
end

#load_file(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE) ⇒ Object



15
16
17
18
# File 'lib/ryodo/suffix_list.rb', line 15

def load_file(suffix_file = Ryodo::PUBLIC_SUFFIX_STORE)
  @suffix_file = suffix_file
  @suffix_data = parse_data << ["example"]
end

#parse_dataObject



11
12
13
# File 'lib/ryodo/suffix_list.rb', line 11

def parse_data
  File.readlines(@suffix_file).map { |line| line.strip.split(".") }
end