Using this itunes search gem, and the documentation seems really straightforward. It fails
with
NameError: uninitialized constant Itunes
gem install itunes-search
Usage
base = Itunes::Base.new
search_object = base.search("term"=>"The Killers")
# get an array of the search_objects
results = search_object.results
results.each ...
Hi chaps,
I am trying to read an HTTP packet via a socket in ruby, and for some reason my code keeps on blocking whilst calling recv
socket = TCPSocket.new("localhost",80)
socket.send r.join("\r\n"), 0
socket.flush
#We're only interested in the string "HTTP/1.1 XXX"
if http_status = get_http_status(socket.recv_nonblock(12))
if http_...
Let say I have class A with some methods in it.
Lets say string methodName is one of those methods, and I already know what parameters I want to give it. They are in a hash {'param1' => value1, 'param2' => value2}
So I have:
params = {'param1' => value1, 'param2' => value2}
a = A.new()
a.send(methodName, value1, value 2) # call metho...
All I want to know is how many bytes Ruby is using for a particular Hash object. How do I do that?
...
So i need this format json and i have this so far
{
query:'Li',
suggestions:['Liberia','Libyan Arab','Liechtenstein','Lithuania'],
data:['LR','LY','LI','LT']
}
query = params[:query]
artists = search_object.map{|x| x["artistName"]}
@all_instances_hash = {}
@all_instances_hash[:query] = query
for instance in artists
@all_...
I'm working on creating a background script that uses EventMachine to connect to a server with WebSockets. The script will be run using DelayedJob or Resque. I've been able to get it to talk to the WebSockets server and send messages, but whenever an error is raised within the EventMachine loop it doesn't crash the script - which is what...
Does anyone know why Im getting this error: initialize': undefined methodgauge' for # (NoMethodError)?! I mean Im using the attr_accessor for the getters and setters for gauge but still it says that I have not declared it. I have below posted a fragment of the code. Thanks in advance.
class ParkingLotGuest < Guest
attr_accessor :gauge,...
I am getting a 'ArgumentError: array size too big' message with the following code:
MAX_NUMBER = 600_000_000
my_array = Array.new(MAX_NUMBER)
Question. What is the max value that the Array.new function takes in Ruby?
...
This is a pretty simple problem im working on in Ruby, but im a total noob so I want to learn the most correct solution. I have a list of data with a name and a value. I need to remember all those (obvious answer: hash). But, i also need to remember the order of this data. SO it looks like:
x=1
y=2
z=3
I was thinking about making an a...
When I upgraded from rubygems 1.3.5 to 1.3.7, my GEM_PATH changed. gem environment gives me
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/me/.gem/ruby/1.8
... whereas it was previously /var/lib/gems/1.8
How would you handle this?
I could set GEM_PATH, but this seems a bit messy, as I'd have to do this for my shell, and each of ...
Say that I have a C program and it has this line:
int a = 12;
Is the value of 12 bound to 'a' during compile time? Or is the value placed into memory during run time when the scope of the program hits 'a'?
What about programming languages like Python and Ruby?
Are there languages/instances where a value is statically bound to a vari...
Hi, I'd like to create a self referencing relation in rails. I have a Person model, and the person should have masters and pupils with same Person object.
So far I tried:
class Person <ActiveRecord::Base
has_many :relationships, :dependent => :destroy
has_many :masters, :through => :relationships, :conditions => "status='master'"...
I've been learning ruby by solving project euler problems and in one solution to a problem I saw you could do something like "12341".chars.inject(1) { |prod, n| prod * n.to_i }.
I've looked on the ruby doc but I can't find where String#chars is defined.
Can anyone explain how that works?
...
I want to iterate an array inside a Ruby heredoc.
<<-BLOCK
Feature: User logs in
In order to post content
As an user
I want to log in
<< Here i want to iterate scenarios >>
BLOCK
"scenarios" is an array I want to loop. For each element I want to print out:
Scenario: #{scenario}
Given
When
Then
So for example if "scenar...
In a Rails3 app, I want to use resourceful paths for an ActiveModel EntityImage representing image file uploads. In some directory I have these files dir/#{type}/#{id}/#{size}.jpg (which are basically all important fields of that class)
Now, probably, because 'id' is a bad name rails wise (it is not domain wise), when I want to make a d...
I am trying to query an HTML page from a website, with a element with id #checkout, checkout has a background-color value which has some hex value, i want to be able to parse that value using nokogiri, in ruby, is it possible? any other way to do this?
...
I have a prepared Nokogiri page where junk is removed... but still the text parts are stored in different nodes...
What I want to do is connecting all direct neighbour text nodes into one single text node...
what I came up with:
#merge neighbour text nodes -> connect content
def merge_text_nodes(node)
previoustext = false
node.chi...
Hi,
could you tell me plz - is it possible to disable warden/devise for one or more controllers/actions?
I need to allow requests with basic auth to one of controllers, but everytime i send similar requests i've seed message, that basi auth is not required for my app.
I'm writing oauth2 provider and its a problem to allow client applic...
Is it possible to create a new Git Repo at GitHub through restful API and not manually through their site?
...
I want to write a Ruby program that will always be running in the background (a daemon) on my mac. Can someone point me in the right direction on how this would be done? Thanks.
...