Newb help with method construction and organization

Hello.
I’m finding myself stuck at a plateau in ruby and hoping to get some
input from others to help me advance a little. My assessment of myself
is that I don’t have a very good grasp on OOP and don’t know when a
method is ‘too big’. When I look at my scripts I don’t feel they
really flow and they resemble my shell scripts just with a different
syntax. Specifically in the example below I have a run method which
then executes the methods that actually do work in a sequential order.
What would be a more common way to organize and invoke the methods?
Any other tips about method or class construction are appreciated. Or
input on anything really.

“— FactFinder Class
require ‘rest-client’
require ‘json’
require ‘yaml’
require ‘puppet’
require ‘time’
require ‘pry’
class FactFinder
attr_accessor :puppetmaster, :nodes, :rest, :nodes_facts
def initialize(*args)
args.first.each_pair {|k,v| instance_variable_set(”@#{k}", “#{v}”) }
@nodes = []
@node_facts = []
@rest = RestClient::Resource.new(“http://#{@puppetmaster}:8000”, {
:headers => { :accept => ‘application/json’}})
end

def run
get_active_nodes
@nodes.each {|n| get_nodes_facts(n) }
write_out_facts
end

def request(path,expected_code=200)
@rest[path].get do |response|
case response.code
when expected_code
yield(response.body)
else
puts “Request for #{path} returned a #{response.code} when we
expected #{expected_code}”
end
end
end
def get_active_nodes
@nodes = request(‘/v1/nodes’) do |response|
JSON.parse(response.body).select do |node|
is_node_active?(node)
end
end
end

def is_node_active?(node)
request(“/status/nodes/#{node}”) do |response|
status = JSON.parse(response)
ts = status.fetch(“catalog_timestamp”,“2013-04-22T05:38:09.855Z”)
return false if ts.nil? or ts.empty?
DateTime.parse(ts.to_s) > (DateTime.now - 14)
end
end

def get_nodes_facts(node)
request(“/facts/#{node}”) do |response|
@node_facts.push(JSON.parse(response))
end
end

def write_out_facts
Dir.mkdir(@facts_path) unless Dir.exists?(@facts_path)
@node_facts.each do |facts|
File.open(“#{@facts_path}/#{facts[“name”]}.yaml”,“w”) do |file|
file << make_facts_compatible(facts)
file.close
end
end
end

def make_facts_compatible(facts_raw)
facts = Puppet::Node::Facts.new(facts_raw[“name”],
facts_raw[“facts”])
facts.to_yaml
end
end

---- Invocation
ff = FactFinder.new({:puppetmaster => ‘somenode.thisplace.net’,
:facts_path => “/var/tmp/facts_new”})

ff.run"

TIA>

Don’t look so bad, methods are short. You should grab a book about OOP,
aside of any programming language.