lghtstkr has quit [Remote host closed the connection]
lightstalker has joined #ruby
jenrzzz_ has quit [Ping timeout: 246 seconds]
jenrzzz_ has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
AndreYuhai has quit [Quit: Leaving]
<LACampbell>
is there a quick and dirty ruby gem that just serves files locally? preferably CLI
jenrzzz_ has quit [Ping timeout: 252 seconds]
<LACampbell>
just for testing, doesn't need to be fast
jasondockers has joined #ruby
<jasondockers>
Is it possible to inject dependencies into rake tasks? I want to test some tasks with rspec and mock out dependencies that call out to github
<havenwood>
KataREEEna: You can make it work by defining a unary !@ method.
<havenwood>
KataREEEna: class Integer; def !@; zero? ? 1 : 0 end end
<KataREEEna>
sure
<KataREEEna>
I mean ideally I just want Ruby to do it
<KataREEEna>
but thanks
<KataREEEna>
I think you answered my question
<havenwood>
KataREEEna: Ruby is flexible enough to work like you'd like but if you want it to work that way out of the box you'll need to design your own language.
<havenwood>
KataREEEna: !anything is `false` except for !nil and !false, which are `true`.
jenrzzz_ has quit [Ping timeout: 252 seconds]
<havenwood>
You're free to define it yourself to mean whatever else. It's best to use a refinement if you do, since you'll break everyone else's code in any gems you're using.
jenrzzz_ has joined #ruby
<havenwood>
&>> module Kata; refine Integer do; def !@; zero? ? 1 : 0; end end end; using Kata; !0
<havenwood>
KataREEEna: That's ^ an example of a refinement of Integer, so you can have this behavior locally without messing up any libraries you'd like to use.
<havenwood>
(Or messing up Ruby standard library, which also relies on unary bang working with default behavior.
<havenwood>
)
<havenwood>
KataREEEna: I guess technically you could just compile Ruby with a patch to make it work like you'd like. A refinement is probably more sensible.
<havenwood>
We can help with a patch or forking Ruby if that's really the way you want to go.
<havenwood>
I like the refinement solution.
<KataREEEna>
nah it's ok
<KataREEEna>
I'd rather be standard
<KataREEEna>
I'm a complete beginner to Ruby
<havenwood>
KataREEEna: Welcome!
<KataREEEna>
thanks
jenrzzz_ has quit [Ping timeout: 268 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
<havenwood>
For "fun" a mathy solution: def unzero(number); (1 - number.abs2 + number.abs2 * 2) / (1 + number.abs2 * 2) end
evdubs__ has joined #ruby
<havenwood>
unzero 0 #=> 1
<havenwood>
unzero 1 => 0
<havenwood>
unzero 42 => 0
<havenwood>
oops, forgot to square it
jenrzzz has joined #ruby
evdubs_ has quit [Ping timeout: 268 seconds]
<leftylink>
what was that one cool definition of signum
<leftylink>
oh no I remember
ur5us__ has quit [Ping timeout: 245 seconds]
<leftylink>
it doesn't work as well in ruby since you have to be a little more explicit
<leftylink>
so obviously in c you wouldn't have th e i[] bits
<havenwood>
leftylink: def signum(x); [x.negative?, x.zero?, x.positive?].index(true).pred end
<leftylink>
hey so that pascal's triangle thing... so surely I am not the first person to have the powers and digits idea, so now I want to konow what it's called... I'll do some searching I guess, I'd assume it'd be called the power method or something
<leftylink>
http://sprunge.us/43Ym5A huh, so they take about the same time to run... honestly, if you were to tell me that ultimately the two things perform the same operation, I might believe it. but I'd have to think a little harder to ese if that's actually true
jenrzzz has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz_ has quit [Ping timeout: 245 seconds]
elcuervo has joined #ruby
cuerbot has quit [Ping timeout: 246 seconds]
Tziltzal has joined #ruby
jenrzzz_ has joined #ruby
teclator has joined #ruby
jenrzzz_ has quit [Ping timeout: 268 seconds]
evdubs_ has joined #ruby
evdubs__ has quit [Ping timeout: 260 seconds]
MalkbabY has joined #ruby
jenrzzz_ has joined #ruby
MalkbabY_ has quit [Ping timeout: 240 seconds]
jenrzzz_ has quit [Ping timeout: 268 seconds]
Pe9le9 has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 260 seconds]
jenrzzz_ has joined #ruby
gearnode has joined #ruby
jenrzzz_ has quit [Ping timeout: 252 seconds]
hkais has quit [Ping timeout: 240 seconds]
jla has joined #ruby
jenrzzz_ has joined #ruby
TomyWork has joined #ruby
evdubs_ has quit [Read error: Connection reset by peer]
evdubs_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 245 seconds]
jenrzzz_ has joined #ruby
vondruch_ has joined #ruby
hkais has joined #ruby
vondruch has quit [Ping timeout: 240 seconds]
vondruch_ is now known as vondruch
jenrzzz_ has quit [Ping timeout: 240 seconds]
jla has quit [Ping timeout: 268 seconds]
KataREEEna has quit [Quit: Connection closed]
BSaboia has quit [Read error: Connection reset by peer]
<whyMe>
if someone could point me what am i doing wrong , I will be happy to continue learing further
<whyMe>
i think i am still a noob in ruby though i had solved some problems before
<whyMe>
!ping
<whyMe>
is my message getting delivered? am i connected ?
* whyMe
Rolls a 6 sided dice and gets 5
<whyMe>
-_-
kashike has quit [Ping timeout: 250 seconds]
<whyMe>
:(
zdv has joined #ruby
<zdv>
Hello, I know nothing about Ruby I just would like to execute the following request via bash: "Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h" Is that possible or in my ignorance I'm asking something very stupid ?
coniptor has quit [Ping timeout: 246 seconds]
<whyMe>
zdv i think you should be using $ ruby -e "your statement"
<whyMe>
but i am not fully sure
jla has quit [Ping timeout: 268 seconds]
<whyMe>
also not sure how ruby or bash would know where to find Redmine and Activity classes
teclator has quit [Ping timeout: 260 seconds]
<adam12>
LACampbell: Before ruby 3.0; ruby -run -e httpd
<zdv>
whyMe I'm afraid you are right, it doesn't seem to find the class: "-e:1:in `<main>': uninitialized constant Redmine (NameError)"
coniptor has joined #ruby
<jhass>
zdv: should be something like bundle exec rails runner '<code>'
<jhass>
add a p or puts to get the output
<whyMe>
thanks jhass
<jhass>
(add in front I should say)
<whyMe>
thanks zdv
<jhass>
whyMe: you se IRC requires some patience, people don't monitor it constantly :)
<jhass>
whyMe: can you add a pastebin with the full unaltered error output you're getting? :)
<adam12>
whyMe: Is the first line of your file the shebang? Or does it actually have ### CODE at the top
<whyMe>
it is shebang
<whyMe>
i put that line to differentiate b/w input and output and stderr below
<jhass>
whyMe: so "def" is defining a new method. Each method gets its own namespace for local variables. They cannout access local variables defined anywhere else. However they share CONSTANTS, @instance_variables and $globals with the context they're defined in
harlin has quit [Read error: Connection reset by peer]
<whyMe>
but av, bv, anv and bnv are global variables right?
harlin has joined #ruby
<adam12>
whyMe: They’re local variables.
<jhass>
no, all variables starting with a lowercase letter are local variables. $globals start with a $, @instance_variables start with @ and CONSTANTS start with an uppercase letter
coniptor has quit [Ping timeout: 240 seconds]
<whyMe>
ooh... ok.. then let me go refresh on the variables again ...
<whyMe>
thanks jhass
coniptor has joined #ruby
<zdv>
jhass whyMe Thank you! now the command seems to be executed but it just returns an empty line, I think I would have to investigate more from redmine side
<jhass>
zdv: do ... 'p <code>' :)
con3 has quit [Excess Flood]
con3 has joined #ruby
<zdv>
jhass "wrong element type Issue at 0 (expected array) (TypeError)"
moldorcoder7 has quit [Quit: %bye mirc%]
<jhass>
zdv: sorry that seems to be a redmine specific error and I know nothing about it at those levels :)
<zdv>
jhass Yes, I guess too, thank you very much for your help!
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
jmcgnh has quit [Ping timeout: 245 seconds]
sagax has quit [Ping timeout: 245 seconds]
con3 has quit [Excess Flood]
d10n-work has quit [Ping timeout: 245 seconds]
con3 has joined #ruby
d10n-work has joined #ruby
jmcgnh has joined #ruby
darthThorik has quit [Ping timeout: 245 seconds]
darthThorik has joined #ruby
coniptor has quit [Ping timeout: 265 seconds]
coniptor has joined #ruby
moldorcoder7 has joined #ruby
factormystic has quit [Read error: Connection reset by peer]
factormystic has joined #ruby
harlin has quit [*.net *.split]
m27frogy has quit [*.net *.split]
thinkpad has quit [*.net *.split]
jess has quit [*.net *.split]
elcuervo has quit [*.net *.split]
lightstalker has quit [*.net *.split]
wallacer has quit [*.net *.split]
nickb has quit [*.net *.split]
noodle has quit [*.net *.split]
sunya7a has quit [*.net *.split]
kloeri has quit [*.net *.split]
x0n has quit [*.net *.split]
tinco has quit [*.net *.split]
levifig has quit [*.net *.split]
volix has quit [*.net *.split]
harlin has joined #ruby
m27frogy has joined #ruby
thinkpad has joined #ruby
lightstalker has joined #ruby
jess has joined #ruby
elcuervo has joined #ruby
x0n has joined #ruby
sunya7a has joined #ruby
nickb has joined #ruby
kloeri has joined #ruby
tinco has joined #ruby
levifig has joined #ruby
volix has joined #ruby
shortdudey123 has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
noodle has joined #ruby
wallacer has joined #ruby
meimeix has quit [Ping timeout: 240 seconds]
shortdudey123 has joined #ruby
Rudd0 has quit [Ping timeout: 240 seconds]
meimeix has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
moldorcoder7 has quit [Quit: %bye mirc%]
jenrzzz has joined #ruby
jetchisel has joined #ruby
jess has quit [Quit: Reconnecting]
jess has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
thinkpad has quit [Ping timeout: 245 seconds]
moldorcoder7 has joined #ruby
linoge has joined #ruby
thinkpad has joined #ruby
thinkpad has quit [Ping timeout: 246 seconds]
NL3limin4t0r_afk is now known as NL3limin4t0r
thinkpad has joined #ruby
thinkpad has quit [Read error: Connection reset by peer]