Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use predefined string when Lexer.debug_enabled? #1159

Merged
merged 2 commits into from
Jun 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/rouge/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def initialize(opts={})
@options = {}
opts.each { |k, v| @options[k.to_s] = v }

@debug = Lexer.debug_enabled? && bool_option(:debug)
@debug = Lexer.debug_enabled? && bool_option('debug')
end

def as_bool(val)
Expand Down Expand Up @@ -365,8 +365,10 @@ def as_token(val)
end

def bool_option(name, &default)
if @options.key?(name.to_s)
as_bool(@options[name.to_s])
name_str = name.to_s

if @options.key?(name_str)
as_bool(@options[name_str])
else
default ? default.call : false
end
Expand Down