fuzzy_time 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
 - data/lib/fuzzy_time.rb +54 -0
 - metadata +59 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            !binary "U0hBMQ==":
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 4 
     | 
    
         
            +
                NjViYjM1ODY5ZjQ0ZDY0MDMzZjZmYjJhZTBkNzk1NTE4ZTJhNmE5Yg==
         
     | 
| 
      
 5 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                OGQ2OGJiZmRhNzIxYmQxMDQ0NWJkOGVmZWM1NDM5MWU1YTRkNzg2ZQ==
         
     | 
| 
      
 7 
     | 
    
         
            +
            !binary "U0hBNTEy":
         
     | 
| 
      
 8 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 9 
     | 
    
         
            +
                ZjQwYjZkMmMzMTkwNDBkMTkxZGE3MmM1ZTQyOGNmNzVkMzdkZTU3N2JjN2Jj
         
     | 
| 
      
 10 
     | 
    
         
            +
                NWRlMGVmZWFiN2VjMmI5OTU0ODZlMTI5MTA4MzkyYjUxMzJiYzIxODZiZGIz
         
     | 
| 
      
 11 
     | 
    
         
            +
                NmM5NDUwMWU5MTJhZmQwYzZjYTE5NThiMTQzNDkwY2VjZjkzYjQ=
         
     | 
| 
      
 12 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 13 
     | 
    
         
            +
                YzU4YThiNTMzZDQyZmJlMWU5YzM3Nzk2YTg3OGYwZmI4MTJhZDQ3NDRkMTRh
         
     | 
| 
      
 14 
     | 
    
         
            +
                ZTgxZmI0OTIzY2FjYjk4YmQ4YTkyZjEwNTc4YjJhNTRjYTRlMjUxMDg5NGVh
         
     | 
| 
      
 15 
     | 
    
         
            +
                NmE1OWU4YzliY2YyYjJiYmJiZDgzMDFhMDQ3MmFiZWJkMzkyYmU=
         
     | 
    
        data/lib/fuzzy_time.rb
    ADDED
    
    | 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Time
         
     | 
| 
      
 2 
     | 
    
         
            +
              # Display the current time in a human-readable format.
         
     | 
| 
      
 3 
     | 
    
         
            +
              #
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Examples
         
     | 
| 
      
 5 
     | 
    
         
            +
              #
         
     | 
| 
      
 6 
     | 
    
         
            +
              #   Time.now.fuzzy
         
     | 
| 
      
 7 
     | 
    
         
            +
              #   # => "half past three"
         
     | 
| 
      
 8 
     | 
    
         
            +
              #
         
     | 
| 
      
 9 
     | 
    
         
            +
              #   Time.local(2013, 1, 1, 5, 46).fuzzy
         
     | 
| 
      
 10 
     | 
    
         
            +
              #   # => "quarter to six"
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def fuzzy
         
     | 
| 
      
 13 
     | 
    
         
            +
                # convert from 24 to 12-hour clock
         
     | 
| 
      
 14 
     | 
    
         
            +
                hour = self.hour % 12
         
     | 
| 
      
 15 
     | 
    
         
            +
                min  = self.min
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                hour = hour + 1 if min >= 33
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                hour = case hour
         
     | 
| 
      
 20 
     | 
    
         
            +
                       when 1; "one"
         
     | 
| 
      
 21 
     | 
    
         
            +
                       when 2; "two"
         
     | 
| 
      
 22 
     | 
    
         
            +
                       when 3; "three"
         
     | 
| 
      
 23 
     | 
    
         
            +
                       when 4; "four"
         
     | 
| 
      
 24 
     | 
    
         
            +
                       when 5; "five"
         
     | 
| 
      
 25 
     | 
    
         
            +
                       when 6; "six"
         
     | 
| 
      
 26 
     | 
    
         
            +
                       when 7; "seven"
         
     | 
| 
      
 27 
     | 
    
         
            +
                       when 8; "eight"
         
     | 
| 
      
 28 
     | 
    
         
            +
                       when 9; "nine"
         
     | 
| 
      
 29 
     | 
    
         
            +
                       when 10; "ten"
         
     | 
| 
      
 30 
     | 
    
         
            +
                       when 11; "eleven"
         
     | 
| 
      
 31 
     | 
    
         
            +
                       when 12, 0; "twelve"
         
     | 
| 
      
 32 
     | 
    
         
            +
                       end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                return "#{hour} o'clock" if min == 0
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                prefix = case min
         
     | 
| 
      
 37 
     | 
    
         
            +
                         when 1..2; "shortly after"
         
     | 
| 
      
 38 
     | 
    
         
            +
                         when 3..7; "five past"
         
     | 
| 
      
 39 
     | 
    
         
            +
                         when 8..12; "ten past"
         
     | 
| 
      
 40 
     | 
    
         
            +
                         when 13..17; "quarter past"
         
     | 
| 
      
 41 
     | 
    
         
            +
                         when 18..22; "twenty past"
         
     | 
| 
      
 42 
     | 
    
         
            +
                         when 23..27; "twentyfive past"
         
     | 
| 
      
 43 
     | 
    
         
            +
                         when 28..32; "half past"
         
     | 
| 
      
 44 
     | 
    
         
            +
                         when 33..37; "twentyfive to"
         
     | 
| 
      
 45 
     | 
    
         
            +
                         when 38..42; "twenty to"
         
     | 
| 
      
 46 
     | 
    
         
            +
                         when 43..47; "quarter to"
         
     | 
| 
      
 47 
     | 
    
         
            +
                         when 48..52; "ten to"
         
     | 
| 
      
 48 
     | 
    
         
            +
                         when 53..57; "five to"
         
     | 
| 
      
 49 
     | 
    
         
            +
                         when 58..59; "nearly"
         
     | 
| 
      
 50 
     | 
    
         
            +
                         end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                "#{prefix} #{hour}"
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,59 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: fuzzy_time
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: '1.1'
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Patrick Lewis
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-02-28 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: Extends Ruby's Time class with a new fuzzy method that returns time in
         
     | 
| 
      
 28 
     | 
    
         
            +
              a human-readable format.
         
     | 
| 
      
 29 
     | 
    
         
            +
            email: get@patricklewis.org
         
     | 
| 
      
 30 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 33 
     | 
    
         
            +
            files:
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/fuzzy_time.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
            homepage: https://github.com/patricklewis/fuzzy_time
         
     | 
| 
      
 36 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 37 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 38 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 39 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 40 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 41 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 43 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 46 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 50 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 51 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 52 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 53 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 54 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 55 
     | 
    
         
            +
            rubygems_version: 2.0.0
         
     | 
| 
      
 56 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 57 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 58 
     | 
    
         
            +
            summary: Human-readable time formatting for Ruby.
         
     | 
| 
      
 59 
     | 
    
         
            +
            test_files: []
         
     |