How to call method of one class in another class

Hi all,

Any help is appreciated.

I have a class namely,

class Web
include HTTParty

headers ‘Accept’ => ‘application/xml’
format :xml

end

And I have another class,

class AtomFormats < HTTParty::Parser
include HTTParty
SupportedFormats.merge!(
{ “application/atom+xml” => :atom}
)
def atom
headers ‘Accept’ => ‘application/atom+xml’
format :atom
end
end

I need to change the headers and format present in Class web to those
parameters present in Class Atomformats.

How can I make a call from Class web to Class Atomformats to make the
change happen

Thanks

Since classes are objects themselves, they also have methods. To define
class methods,

class MyClass
def self.my_method
p self
end
end

MyClass.my_method

Hope this helped.

Michael S. wrote in post #1036318:

Since classes are objects themselves, they also have methods. To define
class methods,

class MyClass
def self.my_method
p self
end
end

MyClass.my_method

Hope this helped.

Hi Michael,

I am confused.

Can you please say the example by editing my code itself.

Thanks in Advance

Not sure why exactly, but nokogiri installed fine on my desktop, but
I’ve been
fighting with the installation for hours on my MacBook Pro. When I did a
search,
it seems that this isn’t limited to nokogiri, and can’t seem to come up
with a
definitive fix. Here is what was logged in the gem_make.out file:

/Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
–with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
checking for libxml/parser.h… *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

/Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:368:in
try_do': The complier failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:452:intry_cpp’
from
/Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:853:in
block in find_header' from /Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:693:inblock in checking_for’
from
/Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in
block (2 levels) in postpone' from /Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:inopen’
from
/Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in
block in postpone' from /Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:inopen’
from
/Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:276:in
postpone' from /Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:692:inchecking_for’
from
/Users/wayneb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:852:in
find_header' from extconf.rb:96:in

I reinstalled the lasted Xcode “just in case”… that didn’t fix
anything.

Anybody have a fix for this? It seems several gems have seen this issue,
so I’m
hoping by posting on the larger ruby list somebody else might have seen
this and
have a solution for it.

Wayne

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs