Class: WebRI::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/webri.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_name) ⇒ Entry

Returns a new instance of Entry.



251
252
253
254
# File 'lib/webri.rb', line 251

def initialize(full_name)
  self.full_name = full_name
  self.paths = []
end

Instance Attribute Details

#full_nameObject

Returns the value of attribute full_name.



249
250
251
# File 'lib/webri.rb', line 249

def full_name
  @full_name
end

#pathsObject

Returns the value of attribute paths.



249
250
251
# File 'lib/webri.rb', line 249

def paths
  @paths
end

Class Method Details

.choices(entries) ⇒ Object

Return hash of choice strings for entries.



257
258
259
260
261
262
263
264
265
266
# File 'lib/webri.rb', line 257

def self.choices(entries)
  choices = {}
  entries.each_pair do |name, entry|
    entry.paths.each do |path|
      choice = self.choice(name, path)
      choices[choice] = path
    end
  end
  Hash[choices.sort]
end

.full_name_for_choice(choice) ⇒ Object

Return the full name from a choice string.



273
274
275
# File 'lib/webri.rb', line 273

def self.full_name_for_choice(choice)
  choice.split(' ').first.sub(/:$/, '')
end

.uri(path) ⇒ Object



268
269
270
# File 'lib/webri.rb', line 268

def self.uri(path)
  URI.parse(path)
end