<apotheon>
quarters: The reason JavaScript works that way is that hash-like things in JavaScript are essentially the equivalent of ruby's BasicObject, in a way. In Ruby, a hash is a particular data structure that happens to be an object (because "everything" is, in Ruby; see small print for exceptions), but most objects are not hashes.
<apotheon>
quarters: A consequence of this difference is that, for instance, allowing hash elements in Ruby to be accessed using message passing syntax would interfere with stuff like hash_instance.public_methods, if you happen to name a hash key :public_methods.
plutes has quit [Read error: Connection reset by peer]
alfiemax has quit [Ping timeout: 250 seconds]
markoong has quit [Ping timeout: 256 seconds]
stapler has joined #ruby
akem has quit [Quit: Leaving]
LDonoughe has joined #ruby
dviola has quit [Quit: WeeChat 2.7.1]
cschneid_ has quit [Ping timeout: 260 seconds]
cschneid_ has joined #ruby
cschneid_ has quit [Client Quit]
ReekenX has joined #ruby
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
LDonoughe has quit [Ping timeout: 240 seconds]
titanbiscuit has quit [Quit: ZNC 1.7.4 - https://znc.in]
titanbiscuit has joined #ruby
gix has quit [Ping timeout: 252 seconds]
mainfram has quit [Quit: Leaving...]
BTRE has quit [Ping timeout: 256 seconds]
drew00 has joined #ruby
alfiemax has joined #ruby
frem has quit [Quit: Connection closed for inactivity]
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
Arkantos has joined #ruby
duckpuppy has joined #ruby
duckpupp- has quit [Ping timeout: 240 seconds]
rmnull has joined #ruby
BTRE has joined #ruby
jetchisel has joined #ruby
alfiemax has quit [Ping timeout: 265 seconds]
ChmEarl has quit [Quit: Leaving]
drincruz_ has joined #ruby
d3bug has quit [Quit: Connection closed for inactivity]
drincruz_ has quit [Ping timeout: 256 seconds]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cliluw has quit [Ping timeout: 264 seconds]
<quarters>
apotheon: thank you
golevka has quit [Read error: Connection reset by peer]
stapler has quit [Quit: Connection closed for inactivity]
mihael_keehl has joined #ruby
<mihael_keehl>
Has anyone worked with rrdtool before?
phenom_ has quit [Ping timeout: 258 seconds]
phenom has joined #ruby
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ReekenX has quit [Quit: Away...]
alfiemax has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
ur5us has quit [Ping timeout: 252 seconds]
ukd1 has quit [Quit: leaving]
djdduty has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
polishdub has joined #ruby
dinfuehr has joined #ruby
quarters has quit [Ping timeout: 240 seconds]
<mihael_keehl>
with File.write() how do I overrite existing files?
<rmnull>
u want to overwrite the content of file
<mihael_keehl>
rmnull: yes, I have File.write(dump_xml, @doc), and I want to overwrite that file so it doesn't give me an error 'File exists'.
<rmnull>
easy way is to open it in write mode, and overwrite. somethin like, File.open(dump_xml, 'w') { |f| f.write(@doc) }
<leftylink>
perhaps my ruby version is different than yours... I don't get any problem when I overwrite with File.write
mayurvpatil has joined #ruby
<mihael_keehl>
Can you take a look at my script? https://pastebin.com/9q2qpun0 It's dumping a xml file, then replacing all NaN values.
<ruby[bot]>
mihael_keehl: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<leftylink>
the only relevant thing I can say at this moment is that `echo a > a; ruby -e 'File.write(?a, ?b)'; cat a` gives b
<leftylink>
which indicates that File.write did overwrite
<leftylink>
so there must be some difference between our two setups
KeyJoo has quit [Quit: KeyJoo]
<leftylink>
I'm sure it will be most enlightening to discover the difference between our two setups
<leftylink>
whatever it may be
stapler has joined #ruby
_whitelogger has joined #ruby
NODE has quit [Quit: changing servers]
NODE has joined #ruby
cd has quit [Quit: cd]
mayurvpatil has quit [Quit: This computer has gone to sleep]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
Arkantos has joined #ruby
alfiemax has quit [Ping timeout: 260 seconds]
hbroadbent has joined #ruby
hbroadbent has left #ruby [#ruby]
hbroadbent has joined #ruby
_whitelogger has joined #ruby
mayurvpatil has joined #ruby
polishdub has quit [Quit: leaving]
lineus_ has joined #ruby
lineus has quit [Ping timeout: 240 seconds]
markopasha has joined #ruby
markopasha has quit [Max SendQ exceeded]
markopasha has joined #ruby
donofrio has quit [Remote host closed the connection]
djdduty has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akem has joined #ruby
code_zombie has quit [Quit: Leaving]
dinfuehr has quit [Ping timeout: 250 seconds]
hbroadbent has quit [Remote host closed the connection]
sergioro has quit [Quit: leaving]
dinfuehr has joined #ruby
alfiemax has joined #ruby
fercell has joined #ruby
djdduty has joined #ruby
sergioro has joined #ruby
sysh has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
hiroaki has quit [Ping timeout: 240 seconds]
postmodern has joined #ruby
conta has joined #ruby
ur5us has joined #ruby
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xpitr has joined #ruby
djdduty has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cthu| has quit [Ping timeout: 256 seconds]
stooj has joined #ruby
arcaos has joined #ruby
hiroaki has joined #ruby
conta has quit [Ping timeout: 256 seconds]
hiroaki has quit [Ping timeout: 256 seconds]
drew00 has left #ruby ["Leaving"]
schne1der has joined #ruby
gix has joined #ruby
dionysus69 has joined #ruby
galaxie has quit [Remote host closed the connection]
galaxie has joined #ruby
elphe has quit [Ping timeout: 265 seconds]
alfiemax has quit [Remote host closed the connection]
zlogan has joined #ruby
galaxie has quit [Remote host closed the connection]
galaxie has joined #ruby
jacksop has joined #ruby
bradfordli123 has joined #ruby
<bradfordli123>
trying to translate ruby into python but I am pretty new in ruby `requests.sort_by!{ |ecr| ecr.start_day }` I think what this snippet of code does is sort IN PLACE the requests array. But I am not sure of the rest of the syntax
<leftylink>
that is true, that it sorts requests in place.
<bradfordli123>
what does the ! do?
<bradfordli123>
reverse? based on .start_day?
<leftylink>
Array#sort_by creates a new array. Array#sort_by! sorts in place.
<leftylink>
they are two methods with different names
<bradfordli123>
ahh gotcha thank you
<yxhuvud>
it is a convention signaling that the user of it should beware. In this case it warns that it is a destructive method
<bradfordli123>
thanks for the tip @yxhuvud
<havenwood>
bradfordli123: Another way to write it is: requests.sort_by!(&:start_day)
<bradfordli123>
havenwood: thank you!
djdduty has joined #ruby
<bradfordli123>
what does the `| |` notation mean? compare each element in the array and sort it by .start_day?
akem_ has joined #ruby
<leftylink>
the thing between | | is/are the argument(s) to the block.
akem_ has quit [Client Quit]
<bradfordli123>
leftylink: i see thank you
akem has quit [Ping timeout: 256 seconds]
djdduty has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jacksop has quit [Remote host closed the connection]
conta has joined #ruby
jacksop has joined #ruby
lurkless has quit [Ping timeout: 256 seconds]
aesthe has joined #ruby
NODE has quit [Quit: changing servers]
jacksop has quit [Ping timeout: 264 seconds]
TomyWork has joined #ruby
NODE has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
davor_ has joined #ruby
davor has quit [Ping timeout: 256 seconds]
davor_ is now known as davor
markopasha has quit [Ping timeout: 260 seconds]
akem has joined #ruby
_whitelogger has joined #ruby
mayurvpatil has quit [Quit: This computer has gone to sleep]
infinityfye has joined #ruby
conta has quit [Quit: conta]
snosk8r has joined #ruby
pandakekok9 has joined #ruby
bradfordli123 has quit [Remote host closed the connection]
elphe has joined #ruby
mayurvpatil has joined #ruby
lurkless has joined #ruby
pandakekok9 has quit [Ping timeout: 256 seconds]
astronautical has joined #ruby
pandakekok9 has joined #ruby
NODE has quit [Quit: changing servers]
NODE has joined #ruby
xco has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pandakekok9 has quit [Ping timeout: 260 seconds]
jacksop has joined #ruby
jacksop has quit [Remote host closed the connection]
sergioro has quit [Ping timeout: 240 seconds]
sergioro has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.7.1]
wgw has quit [Read error: Connection reset by peer]
chamunks has quit [Quit: Don't worry I'm not gone yet.]
mayurvpatil has quit [Quit: Leaving]
al2o3-cr has joined #ruby
chamunks has joined #ruby
snosk8r has quit [Read error: Connection reset by peer]
chalkmonster has quit [Quit: WeeChat 2.7.1]
chalkmonster has joined #ruby
snosk8r has joined #ruby
vondruch has quit [Ping timeout: 264 seconds]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
sergioro has quit [Quit: leaving]
rippa has joined #ruby
postmodern has quit [Quit: Leaving]
fercell_ has joined #ruby
markoong has joined #ruby
vondruch has joined #ruby
code_zombie has joined #ruby
markong has joined #ruby
markoong has quit [Ping timeout: 260 seconds]
kristian_on_linu has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
hiroaki has joined #ruby
drincruz_ has joined #ruby
astronautical has quit [Ping timeout: 250 seconds]
drincruz_ has quit [Ping timeout: 256 seconds]
burningserenity has joined #ruby
vondruch_ has joined #ruby
vondruch has quit [Ping timeout: 260 seconds]
vondruch_ is now known as vondruch
snosk8r has quit [Ping timeout: 240 seconds]
fercell_ has quit [Quit: WeeChat 2.7.1]
snosk8r has joined #ruby
drincruz_ has joined #ruby
gigetoo has quit [Ping timeout: 246 seconds]
gigetoo has joined #ruby
alfiemax has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7.1]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
romanlevin7 has joined #ruby
romanlevin has quit [Ping timeout: 240 seconds]
romanlevin7 is now known as romanlevin
arcaos_ has joined #ruby
arcaos has quit [Ping timeout: 258 seconds]
burningserenity has quit [Remote host closed the connection]
caterfxo is now known as mrwisdom
dinfuehr has quit [Ping timeout: 258 seconds]
dinfuehr has joined #ruby
leitz has joined #ruby
jingjinghack has joined #ruby
d3bug has joined #ruby
cd has joined #ruby
Raboo_ has joined #ruby
alfiemax has quit [Ping timeout: 250 seconds]
kristian_on_linu has quit [Ping timeout: 264 seconds]
NEETzsche has quit [Ping timeout: 246 seconds]
Raboo_ is now known as Raboo
Raboo has quit [Ping timeout: 246 seconds]
chalkmonster has joined #ruby
infinityfye has quit [Quit: Leaving]
titanbiscuit has quit [Quit: ZNC 1.7.4 - https://znc.in]
titanbiscuit has joined #ruby
alfiemax has joined #ruby
_phaul has joined #ruby
kristian_on_linu has joined #ruby
phaul has quit [Ping timeout: 252 seconds]
alfiemax has quit [Ping timeout: 265 seconds]
conta1 has joined #ruby
johnny56 has joined #ruby
johnny56_ has quit [Ping timeout: 256 seconds]
conta1 has quit [Quit: conta1]
jingjinghack has quit [Quit: WeeChat 2.1]
lucasb has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7.1]
advorak has quit [Quit: Leaving]
alfiemax_ has joined #ruby
donofrio has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
<thenori>
This is a very simple problem that I'm surprised I'm having trouble with.
<thenori>
I've never used `case/when` before, so maybe I've made an error with that.
sergioro has joined #ruby
<_phaul>
thenori: what is the task at hand descibed in human terms? My read of it would be count the number of cases where two arrays are different at the same index. But I can be wrong..
<_phaul>
oh, count where left array is smaller in first part of the result, count where left array is larger in the other array of the result. Is this correct? What is your problem with the current solution?
<thenori>
Each person has three scores, s1 s2 s3. Each person's score gets compared to the other's. Whoever's got a bigger score gets a point.
<thenori>
It produces [0, 0] for some reason.
<_phaul>
got it. I think
chalkmonster has joined #ruby
<thenori>
Any ideas?
<_phaul>
yes. case when works slightly differently to how you use it..
<adam12>
thenori: Do you have an example of how you're running it and what value you expect in return?
<havenwood>
&>> [2, 3, 1].zip([2, 2, 2]).map { |left, right| left <=> right }
<_phaul>
case input checks input against each when. when is not supposed to be a boolean, but the value for the index. or you want to use case without casing on index
<thenori>
I'll just use if/elif I guess. I clearly don't understand case/when
<_phaul>
there are 2 distinct ways of using case syntax and you are mixing those.
<_phaul>
if you want to case on the value of index, you write case index, then on when you write when 0, when 1 etc. If you write a boolean expression on when you don't need index after case
LDonoughe has joined #ruby
<_phaul>
so line 10 is just case. not case index
<_phaul>
sorry again. line 10 is just case. not case _input_.
<_phaul>
case 13; when 13; yay; end results in yay. case; when true; yay; end results in yay. but case 13; when true; nope; end does not result in nope
rmnull has quit [Read error: Connection reset by peer]
elphe has joined #ruby
brool has joined #ruby
elphe has quit [Ping timeout: 256 seconds]
dasher00 has quit [Remote host closed the connection]
<brool>
other than ActiveRecord, what might be the best db gem for use with Sinatra? i see menion of data_mapper, but it seems deprecated and the site redirects to rom-rb.org, which i'm reading up on now
<_phaul>
there is sequel... it's worth checking it out
<adam12>
brool: Sequel or ROM, depending on the pattern you want. ROM in some ways is the descendant of DataMapper.
Arkantos has joined #ruby
<brool>
ok. i am already reading up on ROM apparently, and i will look at sequel. i'm writing a simple CRUD app for personal use so i can upload my favorite music list without using gitlab (lol) and basically make my own private cloud storage over CLI. i'm hosting on heroku so i'll need to use postrgres; should i just test & dev with pg as well or would it be worth my while to try to configure my app to
<brool>
use sqlite on my local machine and use pg in production?
<CommunistWolf>
what does lotusrb use? or whaever they renamed lotusrb to
<brool>
lotus-model?
<brool>
i just searched lotus on rubygems
<brool>
looks like it changed to hanamirb
<adam12>
Hanami (Lotus) wraps an older version of ROM. I think they are working to upgrade to a current ROM version but AFAIK it's built on ROM 3.
<brool>
is it another web framework?
<adam12>
brool: Easier to use postgres for both. Not disputing sqlite for it's use but it handles values without strictness which might cause strange bugs in production when postgres complains.
<brool>
or something more specifically built around db
<adam12>
brool: It's another web framework.
<brool>
oic
<brool>
adam12: ok i will just use pg
<brool>
for some reason i had the impression that pg was "big fat overkill"
<adam12>
brool: Sqlite3 is definitely great for a lot of things, but personally I wouldn't mix it with postgres because of how sqlite3 handles data. If you were using sqlite3 for all environments then there'd probably be no issue.
ctOS has quit [Quit: Connection closed for inactivity]
d3bug has quit [Quit: Connection closed for inactivity]
d3bug has joined #ruby
<brool>
sequel looks ezpz
djdduty has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roadie has quit [Ping timeout: 252 seconds]
ur5us has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
roadie has joined #ruby
elphe has joined #ruby
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
LDonoughe has quit [Ping timeout: 258 seconds]
NODE has quit [Quit: changing servers]
NODE has joined #ruby
roadie has quit [Ping timeout: 258 seconds]
NODE has quit [Client Quit]
elphe has quit [Ping timeout: 250 seconds]
NODE has joined #ruby
Arkantos has joined #ruby
schne1der has quit [Ping timeout: 260 seconds]
aesthe has quit [Remote host closed the connection]
wymillerlinux has quit [Remote host closed the connection]
<dorian>
hey question: anybody know of like an IO "window" proxy class, ie you put in some seekable IO thingy and it will wrap the read calls to a specific subset?
djdduty has joined #ruby
LDonoughe has joined #ruby
<dorian>
like say i have a file handle and i want to get some subset of the bytes in it, but some code downstream is ignorant of the actual offsets so i just wrap the file handle in a proxy class along with the offsets
<dorian>
anything like that ring a bell?
mrwisdom has quit [Ping timeout: 258 seconds]
LDonoughe has quit [Ping timeout: 250 seconds]
^amra has quit [Read error: Connection reset by peer]
roadie has joined #ruby
brendan- has quit [Read error: Connection reset by peer]
brendan- has joined #ruby
LDonoughe has joined #ruby
roadie has quit [Ping timeout: 260 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Arkantos has joined #ruby
Esa_ has joined #ruby
olddogbarks has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
<havenwood>
dorian: I usually think of StringIO as a kind of I/O proxy, but it does't have any seek behavior built in. My first thought is just create your own class.
<dorian>
yeah it totally seems like something somebody would have done already though