[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

RSS FEEDS

Newb Newb

8/21/2008 9:17:00 AM

Using Rss Parser I loaded Some Url's into the database.
All The Rss feeds has been stored in the table.
All The Rss Stories Has Been Stored In the Stories Table.
Stories Table Has Fields Like Story Name Story Description
Story Description Fields Contains Images Too...
That Story description must Not Contain Images
I want to restrict the images Not to be shown in the view.
Images has to be displayed separetely.Not Inside the Story Description
field.
I Extracted the Images and dispalyed separately using Hpricot.
But My Story Description Field Shows the Images. I don't Know How to
Restrict the Images To Be Shown..
Any Advices...


My COde Starts Here


require 'rss'
require 'open-uri'
require 'hpricot'

@feeds = Feed.find(:all)
@feeds.each do |f|
puts f.url
feed = RSS::Parser.parse(f.url)


puts "== #{feed.channel.title} =="
puts "channel name: #{feed.channel.title}"
feed.items.each do |item|
puts "Title: #{item.title}"
puts "URL: #{item.link}"

puts "Description: #{item.description}"




@stories = Story.new
@stories.title = item.title
@stories.description = item.description
@stories.feed_id = item.id
@stories.guid = item.guid

doc = Hpricot.parse(item.description)
imgs = doc.search("//img")


@src_array = imgs.collect{|img|img.attributes["src"]}

@src_array = @src_array.to_s


@stories.picture = @src_array
@stories.save

end
end
--
Posted via http://www.ruby-....

16 Answers

Phlip

8/21/2008 11:34:00 AM

0

Newb Newb wrote:

> doc = Hpricot.parse(item.description)
> imgs = doc.search("//img")

> @src_array = imgs.collect{|img|img.attributes["src"]}

Instead of the last line, does this work?

imgs.each do |img|
img.attributes['src'] = nil
end

> @stories.save

Now remember what I said about alternate kinds of images!

--
Phlip

R H Draney

3/31/2010 3:02:00 AM

0

PaulJK filted:
>
>Once upon a time when my ex-wife was still my girlfriend
>she was puzzled when I referred to her jandals as bistables.
>She was my MSc ex-student so I insisted she figure it out
>for herself. I must say after less than a minute she did
>but said it was lame.

Wonder what she'd've thought of referring to this as a "threek":

http://farm1.static.flickr.com/156/392427738_a8fa...

.....r


--
"Oy! A cat made of lead cannot fly."
- Mark Brader declaims a basic scientific principle

Brian M. Scott

3/31/2010 4:39:00 AM

0

On Wed, 31 Mar 2010 17:24:00 +1200, PaulJK
<paul.kriha@paradise.net.nz> wrote in
<news:houigv$gc9$1@news.eternal-september.org> in
sci.lang,alt.religion.kibology,alt.usage.english,sci.physics:

> Brian M. Scott wrote:

>> On Wed, 31 Mar 2010 04:57:47 +1200, PaulJK
>> <paul.kriha@paradise.net.nz> wrote in
>> <news:hot6pr$fal$1@news.eternal-september.org> in
>> sci.lang,alt.religion.kibology,alt.usage.english,sci.physics:

>>> J. Clarke wrote:

>>>> On 3/30/2010 10:27 AM, Doctroid wrote:

>> [...]

>>>>> Zener diode:

>>>>> http://www.reuk.co.uk/OtherImages/current-voltage-graph-zener...

>>> Well? The semiconductors exhibit highly nonlinear
>>> relationship between voltage and their resistance
>>> resulting in nonlinear relationship between voltage and
>>> the current.

>> It seems to me that you (and several others) aren't paying
>> attention to what Doctroid is saying:

> No sorry, Brian, I believe we do pay sufficient attention.
> The thing is that what he and the below quoted "authorities"
> say about applicability of Ohm's law is to us a load of crock.

> The linearity of V-I curve has absolutely nothing to do
> with validity of Ohm's law.

You're still not paying attention: in their framework this
linearity *is* Ohm's law, so in that framework it's absurd
to say that it has nothing to do with the validity of Ohm's
law. In particular, when the term 'x satisfies Ohm's law'
means that the V-I curve for x is linear, then it is
perfectly true that not all materials are ohmic (follow
Ohm's law).

So far as I can tell, you and these authorities -- and scare
quotes are *not* appropriate here -- do not disagree on the
physical facts; you merely mean different things by the term
'Ohm's law'. If you're going to argue, you should at least
argue over the actual point of difference, namely, what
meaning should be assigned to the term 'Ohm's law'.

[...]

Brian

PaulJK

3/31/2010 6:39:00 AM

0

Brian M. Scott wrote:
> On Wed, 31 Mar 2010 17:24:00 +1200, PaulJK
> <paul.kriha@paradise.net.nz> wrote in
> <news:houigv$gc9$1@news.eternal-september.org> in
> sci.lang,alt.religion.kibology,alt.usage.english,sci.physics:
>> Brian M. Scott wrote:
>>> On Wed, 31 Mar 2010 04:57:47 +1200, PaulJK
>>> <paul.kriha@paradise.net.nz> wrote in
>>> <news:hot6pr$fal$1@news.eternal-september.org> in
>>> sci.lang,alt.religion.kibology,alt.usage.english,sci.physics:
>>>> J. Clarke wrote:
>>>>> On 3/30/2010 10:27 AM, Doctroid wrote:
>
>>> [...]
>
>>>>>> Zener diode:
>
>>>>>> http://www.reuk.co.uk/OtherImages/current-voltage-graph-zener...
>
>>>> Well? The semiconductors exhibit highly nonlinear
>>>> relationship between voltage and their resistance
>>>> resulting in nonlinear relationship between voltage and
>>>> the current.
>
>>> It seems to me that you (and several others) aren't paying
>>> attention to what Doctroid is saying:
>
>> No sorry, Brian, I believe we do pay sufficient attention.
>> The thing is that what he and the below quoted "authorities"
>> say about applicability of Ohm's law is to us a load of crock.
>
>> The linearity of V-I curve has absolutely nothing to do
>> with validity of Ohm's law.
>
> You're still not paying attention: in their framework this
> linearity *is* Ohm's law,

Yes, Brian, I well understand their point of view.
The disagreement is indeed as you say about what
meaning should be assigned to the term 'Ohm's law'.

What I (and some others in this thread) were taught
was that Ohm's law was V=IR. (fullstop)
No linearity is implied. It is equally applicable in conductors
with variable non-linear resistance/reactance and
equally applies in complex high frequency environments.
It is obeyed and applicable everywhere in nature even in
complex non-linear environments, like brain and nerves
or in lightnings.

I don't know if this was the way the law was understood by
Ohm in its year naught, but that was the modern version
of the law I was taught and used in differential equations,
Laplace and Z transforms describing the behaviour of the
el.circuits.

The reason for my disagreeing with "them" is not for the
lack of attention, we simply disagree on that fundamental
level of what is and isn't Ohm's law.

pjk

> so in that framework it's absurd
> to say that it has nothing to do with the validity of Ohm's
> law. In particular, when the term 'x satisfies Ohm's law'
> means that the V-I curve for x is linear, then it is
> perfectly true that not all materials are ohmic (follow
> Ohm's law).
>
> So far as I can tell, you and these authorities -- and scare
> quotes are *not* appropriate here -- do not disagree on the
> physical facts; you merely mean different things by the term
> 'Ohm's law'. If you're going to argue, you should at least
> argue over the actual point of difference, namely, what
> meaning should be assigned to the term 'Ohm's law'.
>
> [...]
>
> Brian

ke10

3/31/2010 5:11:00 PM

0

In article <houmt9$sj7$2@news.eternal-september.org>,
PaulJK <paul.kriha@paradise.net.nz> wrote:
>Brian M. Scott wrote:
>>
>> You're still not paying attention: in their framework this
>> linearity *is* Ohm's law,
>
>Yes, Brian, I well understand their point of view.
>The disagreement is indeed as you say about what
>meaning should be assigned to the term 'Ohm's law'.
>
>What I (and some others in this thread) were taught
>was that Ohm's law was V=IR. (fullstop)

I've been waiting for someone to say what Brian has just said. You were taught
to use a particular expression to mean X; others were taught (by equally
reputable authorities) to use it to mean Y.

Maybe you could all live with it, rather than squabbling about each other's
qualifications in physics?

Now one party or the other could say "but definition X is more *useful* than
definition Y, because it makes certain discussions clearer". That would be a
tenable view, but asserting that either definition is fundamentally wrong is
about as much use as disputing about angels on the head of a pin.

Katy


Mark Edwards

3/31/2010 6:35:00 PM

0


[Ohm's Law arguments]

No cluons were harmed when ke10@cam.ac.uk wrote:
>That would be a tenable view, but asserting that either definition is
>fundamentally wrong is about as much use as disputing about angels
> on the head of a pin.

I find your attempt to use Ohm's Law to zap angels vaguely disturbing.


Mark Edwards
--
Proof of Sanity Forged Upon Request

Robert Bannister

4/1/2010 12:27:00 AM

0

Mark Edwards wrote:
> [Ohm's Law arguments]
>
> No cluons were harmed when ke10@cam.ac.uk wrote:
>> That would be a tenable view, but asserting that either definition is
>> fundamentally wrong is about as much use as disputing about angels
>> on the head of a pin.
>
> I find your attempt to use Ohm's Law to zap angels vaguely disturbing.

They are bound to resist.

--

Rob Bannister

J. Clarke

4/1/2010 5:16:00 AM

0

On 3/31/2010 8:26 PM, Robert Bannister wrote:
> Mark Edwards wrote:
>> [Ohm's Law arguments]
>>
>> No cluons were harmed when ke10@cam.ac.uk wrote:
>>> That would be a tenable view, but asserting that either definition is
>>> fundamentally wrong is about as much use as disputing about angels
>>> on the head of a pin.
>>
>> I find your attempt to use Ohm's Law to zap angels vaguely disturbing.
>
> They are bound to resist.

What is the resistance of an angel anyway?


Evan Kirshenbaum

4/1/2010 6:19:00 AM

0

"PaulJK" <paul.kriha@paradise.net.nz> writes:

> Yes, Brian, I well understand their point of view.
> The disagreement is indeed as you say about what
> meaning should be assigned to the term 'Ohm's law'.
>
> What I (and some others in this thread) were taught was that Ohm's
> law was V=IR. (fullstop) No linearity is implied. It is equally
> applicable in conductors with variable non-linear
> resistance/reactance and equally applies in complex high frequency
> environments. It is obeyed and applicable everywhere in nature even
> in complex non-linear environments, like brain and nerves or in
> lightnings.
>
> I don't know if this was the way the law was understood by Ohm in
> its year naught, but that was the modern version of the law I was
> taught and used in differential equations, Laplace and Z transforms
> describing the behaviour of the el.circuits.

It apparently wasn't the way the law was understood by, among others,
Maxwell:

The statement of Ohm's law is that, for a conductor in a given
state, the electromotive force is proportional to the current
produced. The quotient of the numerical value of the
electromotive force divided by the numerical value of the current
is defined as the resistance of the conductor; and Ohm's law
asserts that the resistance, as thus defined, does not vary with
the strength of the current.

Report of the Committee, consisting of Professor
Clerk Maxwell, Professor J.D. Everett, and
Dr. A. Schuster, for Testing Experimentally
Ohm's Law, _Report of the Forty-Sixth Meeting of
the British Association for the Advancement of
Science_, 1876.

Their conclusion was that, within the limits of experimental error, it
appeared to be true. Just a few years later I see people talking
about violations of Ohm's Law, also implying that it requires
linearity, e.g.,

.... which does not conduct according to Ohm's law, but with a
resistance deminishing as the electromotive force increases.

J. Hopkinson, _The Telegraphic Journal_, August
1, 1879

This is still the way it's stated in textbooks in the twentieth
century:

78. Ohm's Law.--When an e.m.f. is applied to the terminals of a
conductor, a current is produced which is directly proportional to
the e.m.f. and is inversely proportional to the resistance of the
conductor.
Clarence Christie, _Electrical Engineering_,
1917

> The reason for my disagreeing with "them" is not for the
> lack of attention, we simply disagree on that fundamental
> level of what is and isn't Ohm's law.

Can you point to something published that describes Ohm's Law without
implying linearity?

--
Evan Kirshenbaum +------------------------------------
HP Laboratories |When correctly viewed,
1501 Page Mill Road, 1U, MS 1141 | Everything is lewd.
Palo Alto, CA 94304 |I could tell you things
| about Peter Pan,
kirshenbaum@hpl.hp.com |and the Wizard of Oz--
(650)857-7572 | there's a dirty old man!
| Tom Lehrer
http://www.kirshe...

Lewis

4/1/2010 6:31:00 AM

0

In message <81i7i6FmgdU2@mid.individual.net>
Robert Bannister <robban1@bigpond.com> wrote:
> Mark Edwards wrote:
>> [Ohm's Law arguments]
>>
>> No cluons were harmed when ke10@cam.ac.uk wrote:
>>> That would be a tenable view, but asserting that either definition is
>>> fundamentally wrong is about as much use as disputing about angels
>>> on the head of a pin.
>>
>> I find your attempt to use Ohm's Law to zap angels vaguely disturbing.

> They are bound to resist.

It's not just a good idea, it's the law.

--
Get in there you big furry oaf! I don't care what you smell!