Class: CodeUnion::Search::ResultPresenter

Inherits:
Object
  • Object
show all
Includes:
Helpers::Text
Defined in:
lib/codeunion/search.rb

Overview

Prepares a search result for presentation in the CLI

Constant Summary collapse

EXCERPT_REGEX =
/<match>([^<]*)<\/match>/

Instance Method Summary collapse

Methods included from Helpers::Text

#format_output, #indent, #wrap

Constructor Details

#initialize(result) ⇒ ResultPresenter

Returns a new instance of ResultPresenter.



11
12
13
# File 'lib/codeunion/search.rb', line 11

def initialize(result)
  @result = result
end

Instance Method Details

#to_sObject



15
16
17
18
19
# File 'lib/codeunion/search.rb', line 15

def to_s
  [:name, :description, :url, :tags, :excerpt].map do |attribute|
    format_output(send(attribute))
  end.join("\n")
end