Few Questions on Ruby

A

Anil Bhat

Given this module definition:

module Greeting
def say_hello
puts "Hello, my name is #{self.name}"
end
end

1.) How to implement a class Foo using the Greeting module so that the
following code example generates the expected output. Do not implement a
say_hello method.
foo = Foo.new("Fred")
foo.say_hello
2.) How to Implement a class Bar using the Greeting module so that the
following code example generates the expected output. Do not implement a
say_hello method.

Bar.say_hello

3.) Given this class:

class Example
@name
end

How would you describe the @name variable? Assume you have access
to this source code but can't change it. How would you add methods to
the Example class to set and get the value of @name?
4.) In a Rails application, if it takes a long time for a page to load.
If there is an action that dynamically generates a large binary file and
sends this to clients via send_data. How is this related to the slow
response time? What change can we make to avoid this?
 
M

Marius Žilėnas

Hello:),

1)
module Greeting
def say_hello
puts "Hello, my name is #{self.name}"
end
end

class Foo
attr_accessor :name
include Greeting

def initialize(name)
@name = name
end

end

2)
class Bar
extend Greeting
end

3)

class Example

attr_accessor :name

end

4) Client waits until request finishes even if client doesn't download
any data. Implement a background service to generate large files,
implement user notification service to notify user after file is
generated and ready to use.


Marius Žilėnas
(e-mail address removed)
 
R

Robert Klemme

Given this module definition:

....

This looks suspiciously like homework or interview questions. What is
your motivation for posting this seemingly unrelated list of questions /
tasks?

robert
 
Y

Yaser Sulaiman

[Note: parts of this message were removed to make it a legal post.]

This looks suspiciously like homework or interview questions. What is
your motivation for posting this seemingly unrelated list of questions /
tasks?
I can has homework solutionz! :)
 
T

Todd Benson

T24gTW9uLCBEZWMgMjksIDIwMDggYXQgMjozOSBBTSwgTWFyaXVzIN5pbOtuYXMgPG16aWxlbmFz
QGdtYWlsLmNvbT4gd3JvdGU6Cj4gSGVsbG86KSwKPgo+IDEpCj4gbW9kdWxlIEdyZWV0aW5nCj4g
IGRlZiBzYXlfaGVsbG8KPiAgICBwdXRzICJIZWxsbywgbXkgbmFtZSBpcyAje3NlbGYubmFtZX0i
Cj4gIGVuZAo+IGVuZAo+Cj4gY2xhc3MgRm9vCj4gIGF0dHJfYWNjZXNzb3IgOm5hbWUKPiAgaW5j
bHVkZSBHcmVldGluZwo+Cj4gIGRlZiBpbml0aWFsaXplKG5hbWUpCj4gICAgQG5hbWUgPSBuYW1l
Cj4gIGVuZAo+Cj4gZW5kCj4KPiAyKQo+IGNsYXNzIEJhcgo+ICBleHRlbmQgR3JlZXRpbmcKPiBl
bmQKCkkgbGlrZSB0aGUgZmFjdCB5b3UgY2FuIGV4dGVuZCBzaW5nbGUgaW5zdGFuY2VzLCB0b28u
Li4KCmYgPSBGb28ubmV3CmYuZXh0ZW5kIE15TW9kdWxlCgpUb2RkCg==
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,730
Latest member
AudryNolan

Latest Threads

Top