Author

Topic: Bitpay RubyGem (Read 926 times)

legendary
Activity: 2271
Merit: 1363
August 24, 2012, 08:30:54 AM
#5
Thank you for your nice feedback.  Smiley

I'm glad someone looked at it.

And yes it's working, the file you've been inspecting is an artifact i forgot in there.
I moved the stuff into the other file because i'm still figuring out method calls.
hero member
Activity: 938
Merit: 1000
August 24, 2012, 04:35:10 AM
#4
Since you said you are learning ruby I would have some pointers.

1. Ruby uses camel-case for class names and underscores for variables and methods. Also try to use two spaces for tabs and use them consistently.
Code:
class BPLIB > class BpLib
bpCreateInvoice -> bp_create_invoice
etc.

You can read more about the Ruby style in this website.

2. You can make this a one liner if you would want to

Code:
options = @options.merge(options)
options[:price] = price
options[:orderId]= orderid
options[:posData]= posData

options = @options.merge(options).merge({:price => price, :orderId => orderid, :postDate => posData})

3. I would probably rewrite this bit using has_key? since I find it increases readability.

Code:
  postOptions.each_with_index do |opt,index|
    if options.include(opt[index])
      postdata[index] = options[index]
    end
  end

postOptions.each do |key|
  if @options.has_key?(key)
    postdata[key] = @options[key]
  end
end

4. Is the code actually working? It seems you define postdata after you try to fill it.

Hope these tips help Smiley
legendary
Activity: 2271
Merit: 1363
August 24, 2012, 04:08:16 AM
#3
Why don't you just call it bitpay ?

I am bad at choosing names.  Cry
legendary
Activity: 1372
Merit: 1008
1davout
August 24, 2012, 04:02:57 AM
#2
Why don't you just call it bitpay ?
legendary
Activity: 2271
Merit: 1363
August 23, 2012, 04:36:48 PM
#1
Hi Guys,

since i am learning Ruby i thought it would be cool to create a Ruby Gem for Bitpay.
You can create and request invoices from the Bitpay Api in an easy way.

Here it is :

https://github.com/phanaster/BP-for-Ruby

If you encounter any bugs, have advice, suggestions, or feedback of any kind, i would appreciate it.

Have fun !

Disclaimer : This is an Alpha Release. Keep this in mind, it probably can break or malfunction. Even if my tests did not show any bugs or misbehavior, its not perfect.
Jump to: