Skip to content

Commit

Permalink
tighter code style
Browse files Browse the repository at this point in the history
  • Loading branch information
nakajima committed Jan 30, 2009
1 parent 7fd99be commit 2e55b7f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/elementor/result.rb
Expand Up @@ -42,15 +42,14 @@ def element_names

# Returns the raw Nokogiri doc once a method has been called
# on the dispatcher. Up until that point, returns nil.
def doc(markup=nil)
if html = markup || content
@doc = nil if markup
parser = opts[:as].to_sym rescue nil
@doc ||= case parser
when nil, :html then Nokogiri::HTML(html)
when :xml then Nokogiri::XML(html)
else raise InvalidParser.new("Nokogiri cannot parse as '#{opts[:as]}'. Please request :xml or :html.")
end
def doc(new_markup=nil)
if markup = new_markup || content
@doc = nil if new_markup
@doc ||= case parser.to_sym
when :xml then Nokogiri::XML(markup)
when :html then Nokogiri::HTML(markup)
else raise InvalidParser.new("Nokogiri cannot parse as '#{parser.inspect}'. Please request :xml or :html.")
end
end
end

Expand All @@ -66,6 +65,10 @@ def doc_ready!

private

def parser
opts[:as] || :html
end

# Blank slate context for defining element names.
def naming_context
@naming_context ||= blank_context(:this => self) do
Expand Down

0 comments on commit 2e55b7f

Please sign in to comment.