Skip to content

Commit

Permalink
Version 0.0.2 Added Symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Slaughter committed Sep 30, 2013
1 parent 513eeb1 commit 50fb334
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec/reports
test/tmp
test/version_tmp
tmp
Gemfile.lock

# YARD artifacts
.yardoc
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
to_bool (0.0.1)
to_b (0.0.2)

GEM
remote: http://rubygems.org/
Expand Down Expand Up @@ -41,5 +41,5 @@ DEPENDENCIES
coveralls (~> 0.6.7)
rake
rspec (~> 2.13.0)
to_bool!
to_b!
yard
15 changes: 15 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# History
## Released Versions
### Version 0.0.2
#### Patch: Symbol
##### Added
* Symbol

##### Changed
* All get converted to string first

### Version 0.0.1
#### Patch: Inital Code. Fixnum, String
##### Added
* Fixnum
* String
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,37 @@ to_bool
[![Gem Version](https://badge.fury.io/rb/to_b.png)](http://badge.fury.io/rb/to_b)

Extends classes to include the to_b method
Currently Extends:
* Fixnum
* String
* Symbol

```ruby
gem install to_b
```

```ruby
require 'to_bool'
```

```ruby
1.to_b
=> true

'yes'.to_b
=> true

:t.to_b
=> true
```

```ruby
0.to_b
=> false

'no'.to_b
=> false

:f.to_b
=> false
```
4 changes: 4 additions & 0 deletions lib/to_bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ class String

class Fixnum
include Bool
end

class Symbol
include Bool
end
6 changes: 3 additions & 3 deletions lib/to_bool/bool.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Bool
def to_b
case self
when /true/i, /yes/i, /t/i, /1/i, 1
case self.to_s
when /true/i, /yes/i, /t/i, /1/i
true
when /false/i, /no/i, /f/i, /0/i, 0
when /false/i, /no/i, /f/i, /0/i
false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/to_bool/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Bool
VERSION = "0.0.1".freeze
VERSION = "0.0.2".freeze
DATE = "2013-09-30".freeze
end
29 changes: 29 additions & 0 deletions spec/symbol_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'helper'

describe Symbol do
describe "#to_b" do
it "returns true when true" do
expect(:true.to_b).to be true
end

it "returns true when yes" do
expect(:yes.to_b).to be true
end

it "returns true when t" do
expect(:t.to_b).to be true
end

it "returns false when false" do
expect(:false.to_b).to be false
end

it "returns false when no" do
expect(:no.to_b).to be false
end

it "returns false when f" do
expect(:f.to_b).to be false
end
end
end

0 comments on commit 50fb334

Please sign in to comment.