Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
- Loading branch information
Showing
9 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
class Object | ||
## | ||
# Returns true if the object is nil or empty (if applicable) | ||
# | ||
# [].blank? #=> true | ||
# [1].blank? #=> false | ||
# [nil].blank? #=> false | ||
# | ||
# @return [TrueClass, FalseClass] | ||
# | ||
# @api public | ||
def blank? | ||
nil? || (respond_to?(:empty?) && empty?) | ||
end | ||
end # class Object | ||
|
||
class Numeric | ||
## | ||
# Numerics are never blank | ||
# | ||
# 0.blank? #=> false | ||
# 1.blank? #=> false | ||
# 6.54321.blank? #=> false | ||
# | ||
# @return [FalseClass] | ||
# | ||
# @api public | ||
def blank? | ||
false | ||
end | ||
end # class Numeric | ||
|
||
class NilClass | ||
## | ||
# Nil is always blank | ||
# | ||
# nil.blank? #=> true | ||
# | ||
# @return [TrueClass] | ||
# | ||
# @api public | ||
def blank? | ||
true | ||
end | ||
end # class NilClass | ||
|
||
class TrueClass | ||
## | ||
# True is never blank. | ||
# | ||
# true.blank? #=> false | ||
# | ||
# @return [FalseClass] | ||
# | ||
# @api public | ||
def blank? | ||
false | ||
end | ||
end # class TrueClass | ||
|
||
class FalseClass | ||
## | ||
# False is always blank. | ||
# | ||
# false.blank? #=> true | ||
# | ||
# @return [TrueClass] | ||
# | ||
# @api public | ||
def blank? | ||
true | ||
end | ||
end # class FalseClass | ||
|
||
class String | ||
## | ||
# Strips out whitespace then tests if the string is empty. | ||
# | ||
# "".blank? #=> true | ||
# " ".blank? #=> true | ||
# " hey ho ".blank? #=> false | ||
# | ||
# @return [TrueClass, FalseClass] | ||
# | ||
# @api public | ||
def blank? | ||
strip.empty? | ||
end | ||
end # class String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'extlib' | ||
require 'extlib/blank' | ||
|
||
require 'flat/version' | ||
require 'flat/file' | ||
|
||
module Flat #:nodoc | ||
include Extlib | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Flat #:nodoc: | ||
VERSION = "0.1.4" | ||
VERSION = "0.1.5" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters