tbmx 0.5.0 → 0.5.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.
- data/lib/tbmx.rb +48 -18
- metadata +1 -1
    
        data/lib/tbmx.rb
    CHANGED
    
    | @@ -290,14 +290,52 @@ module TBMX | |
| 290 290 | 
             
                  when "bookmarks-folder-id", "bookmarks_folder_id", "bookmarks_folder-id", "bookmarks-folder_id",
         | 
| 291 291 | 
             
                       "bookmark-folder-id",  "bookmark_folder_id",  "bookmark_folder-id",  "bookmark-folder_id"
         | 
| 292 292 | 
             
                    bookmarks_folder_id_command_handler
         | 
| 293 | 
            +
                  when "pi"
         | 
| 294 | 
            +
                    "#{Math::PI}"
         | 
| 295 | 
            +
                  when "e"
         | 
| 296 | 
            +
                    "#{Math::E}"
         | 
| 293 297 | 
             
                  when "+"
         | 
| 294 | 
            -
                     | 
| 298 | 
            +
                    reducable_math_function_handler :+
         | 
| 295 299 | 
             
                  when "-"
         | 
| 296 | 
            -
                     | 
| 300 | 
            +
                    reducable_math_function_handler :-
         | 
| 297 301 | 
             
                  when "*"
         | 
| 298 | 
            -
                     | 
| 302 | 
            +
                    reducable_math_function_handler :*
         | 
| 299 303 | 
             
                  when "/"
         | 
| 300 | 
            -
                     | 
| 304 | 
            +
                    reducable_math_function_handler :/
         | 
| 305 | 
            +
                  when "sin"
         | 
| 306 | 
            +
                    math_function_handler :sin
         | 
| 307 | 
            +
                  when "cos"
         | 
| 308 | 
            +
                    math_function_handler :cos
         | 
| 309 | 
            +
                  when "tan"
         | 
| 310 | 
            +
                    math_function_handler :tan
         | 
| 311 | 
            +
                  when "asin"
         | 
| 312 | 
            +
                    math_function_handler :asin
         | 
| 313 | 
            +
                  when "acos"
         | 
| 314 | 
            +
                    math_function_handler :acos
         | 
| 315 | 
            +
                  when "atan"
         | 
| 316 | 
            +
                    math_function_handler :atan
         | 
| 317 | 
            +
                  when "sinh"
         | 
| 318 | 
            +
                    math_function_handler :sinh
         | 
| 319 | 
            +
                  when "cosh"
         | 
| 320 | 
            +
                    math_function_handler :cosh
         | 
| 321 | 
            +
                  when "tanh"
         | 
| 322 | 
            +
                    math_function_handler :tanh
         | 
| 323 | 
            +
                  when "asinh"
         | 
| 324 | 
            +
                    math_function_handler :asinh
         | 
| 325 | 
            +
                  when "acosh"
         | 
| 326 | 
            +
                    math_function_handler :acosh
         | 
| 327 | 
            +
                  when "atanh"
         | 
| 328 | 
            +
                    math_function_handler :atanh
         | 
| 329 | 
            +
                  when "erfc"
         | 
| 330 | 
            +
                    math_function_handler :erfc
         | 
| 331 | 
            +
                  when "gamma"
         | 
| 332 | 
            +
                    math_function_handler :gamma
         | 
| 333 | 
            +
                  when "lgamma"
         | 
| 334 | 
            +
                    math_function_handler :lgamma
         | 
| 335 | 
            +
                  when "log10"
         | 
| 336 | 
            +
                    math_function_handler :log10
         | 
| 337 | 
            +
                  when "log2"
         | 
| 338 | 
            +
                    math_function_handler :log2
         | 
| 301 339 | 
             
                  else
         | 
| 302 340 | 
             
                    command_error "unknown command #{command.to_html}"
         | 
| 303 341 | 
             
                  end
         | 
| @@ -311,7 +349,7 @@ module TBMX | |
| 311 349 | 
             
                  %{<a href="#{TB_COM}/#{target}">#{string}</a>}
         | 
| 312 350 | 
             
                end
         | 
| 313 351 |  | 
| 314 | 
            -
                def  | 
| 352 | 
            +
                def numbers_from_expressions
         | 
| 315 353 | 
             
                  expressions
         | 
| 316 354 | 
             
                    .map do |number|
         | 
| 317 355 | 
             
                      begin
         | 
| @@ -319,23 +357,15 @@ module TBMX | |
| 319 357 | 
             
                      rescue ArgumentError
         | 
| 320 358 | 
             
                        nil
         | 
| 321 359 | 
             
                      end
         | 
| 322 | 
            -
                    end.reject | 
| 323 | 
            -
                end
         | 
| 324 | 
            -
             | 
| 325 | 
            -
                def addition
         | 
| 326 | 
            -
                  reducable_math_function_handler :+
         | 
| 360 | 
            +
                    end.reject &:nil?
         | 
| 327 361 | 
             
                end
         | 
| 328 362 |  | 
| 329 | 
            -
                def  | 
| 330 | 
            -
                   | 
| 331 | 
            -
                end
         | 
| 332 | 
            -
             | 
| 333 | 
            -
                def multiplication
         | 
| 334 | 
            -
                  reducable_math_function_handler :*
         | 
| 363 | 
            +
                def reducable_math_function_handler(function)
         | 
| 364 | 
            +
                  numbers_from_expressions.reduce function
         | 
| 335 365 | 
             
                end
         | 
| 336 366 |  | 
| 337 | 
            -
                def  | 
| 338 | 
            -
                   | 
| 367 | 
            +
                def math_function_handler(function)
         | 
| 368 | 
            +
                  Math.send function, numbers_from_expressions.first
         | 
| 339 369 | 
             
                end
         | 
| 340 370 |  | 
| 341 371 | 
             
                def user_command_handler
         |