class Nutrella::BoardNameResolver

Knows how to take the supplied board name and resolve it to a Trello board url.

Public Class Methods

new(url_cache, search_specification) click to toggle source
# File lib/nutrella/board_name_resolver.rb, line 6
def initialize(url_cache, search_specification)
  @url_cache = url_cache
  @search_specification = search_specification
end

Public Instance Methods

resolve(board_name, &block) click to toggle source
# File lib/nutrella/board_name_resolver.rb, line 11
def resolve(board_name, &block)
  matching_url(board_name) || cached_url(board_name, &block)
end

Private Instance Methods

cached_url(board_name, &block) click to toggle source
# File lib/nutrella/board_name_resolver.rb, line 25
def cached_url(board_name, &block)
  @url_cache.fetch(board_name, &block)
end
matching_url(board_name) click to toggle source
# File lib/nutrella/board_name_resolver.rb, line 17
def matching_url(board_name)
  return nil unless @search_specification.match?(board_name)

  search_reg_exp = Regexp.new(board_name, Regexp::IGNORECASE)

  @url_cache.search(search_reg_exp)
end