Skip to content

Commit 0f04036

Browse files
committed
Helpers to DRY up option handling.
1 parent bcf034e commit 0f04036

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/annotate.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,18 @@ def self.load_tasks
1919
return false
2020
end
2121
end
22+
23+
def self.fallback(*args)
24+
return args.detect { |arg| !arg.blank? }
25+
end
26+
27+
def self.true?(val)
28+
return false if(val.blank?)
29+
return false unless(val =~ TRUE_RE)
30+
return true
31+
end
32+
33+
private
34+
35+
TRUE_RE = /^(true|t|yes|y|1)$/i
2236
end

0 commit comments

Comments
 (0)