vlad_starkov has quit [Read error: Connection reset by peer]
havenwood has joined #ruby-lang
jonahR has quit [Quit: jonahR]
brianpWi1s has joined #ruby-lang
brianpWi1s has quit [Client Quit]
arooni-mobile has joined #ruby-lang
brianpWi1s has joined #ruby-lang
jayne has quit [Quit: Quit]
breakingthings has quit []
jayne has joined #ruby-lang
brianpWi1s has quit [Client Quit]
brianpWi1s has joined #ruby-lang
sandbags has quit []
benanne has quit [Quit: kbai]
kiwnix has joined #ruby-lang
stonerfish has quit [Quit: Leaving.]
brianpWi1s has quit [Quit: leaving]
jonahR has joined #ruby-lang
wallerdev has joined #ruby-lang
arooni-mobile has quit [Remote host closed the connection]
ender has joined #ruby-lang
ender_ has joined #ruby-lang
|jemc| has quit [Ping timeout: 272 seconds]
vlad_starkov has joined #ruby-lang
Onixs_ has quit [Read error: Connection reset by peer]
jay_m has quit [Remote host closed the connection]
fijimunkii has quit [Ping timeout: 265 seconds]
jay_m has joined #ruby-lang
Onixs has joined #ruby-lang
ender has quit [Ping timeout: 252 seconds]
jay_m has quit [Remote host closed the connection]
jay_m has joined #ruby-lang
elia has quit [Quit: Computer has gone to sleep.]
jsullivandigs has quit [Remote host closed the connection]
vlad_starkov has quit [Ping timeout: 272 seconds]
apeiros has quit [Remote host closed the connection]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
apeiros has joined #ruby-lang
fijimunkii has joined #ruby-lang
tylersmith has quit [Remote host closed the connection]
fijimunkii has quit [Ping timeout: 260 seconds]
seanlinsley has joined #ruby-lang
danijoo_ has quit [Read error: Connection reset by peer]
danijoo has joined #ruby-lang
atmosx has quit [Quit: Lost in trance]
jay_m has quit [Quit: Leaving...]
ivanskie has quit [Ping timeout: 272 seconds]
jay_m has joined #ruby-lang
Xuisce has joined #ruby-lang
jay_m has quit [Client Quit]
Xuisce is now known as jay_m
diegoviola has joined #ruby-lang
tom025 has joined #ruby-lang
vpretzel has quit [Quit: Adios!]
cnivolle has quit [Remote host closed the connection]
lfox has quit [Quit: ZZZzzz…]
marr has quit [Ping timeout: 246 seconds]
RobertBi_ has joined #ruby-lang
kiwnix has quit [Read error: Connection reset by peer]
workmad3 has quit [Ping timeout: 252 seconds]
RobertBi_ has quit [Client Quit]
RobertBirnie has quit [Ping timeout: 252 seconds]
mistym has quit [Remote host closed the connection]
benlovell has joined #ruby-lang
achru has joined #ruby-lang
pabloh has joined #ruby-lang
jerrytgarcia has quit [Quit: WeeChat 0.4.2]
benlovell has quit [Ping timeout: 252 seconds]
achru has quit [Ping timeout: 272 seconds]
jtw has quit []
dwknoxy has quit [Quit: Computer has gone to sleep.]
bzalasky has joined #ruby-lang
bottico has quit [Quit: Leaving.]
quizzicol has joined #ruby-lang
symm- has quit [Ping timeout: 252 seconds]
dik_dak has quit [Quit: Leaving]
MrZYX is now known as MrZYX|off
bzalasky has quit [Remote host closed the connection]
jsullivandigs has joined #ruby-lang
brianpWins has quit [Quit: brianpWins]
mannyt has joined #ruby-lang
VTLob has quit [Quit: VTLob]
Johz has quit [Quit: Leaving]
deens has joined #ruby-lang
presidentbeef has joined #ruby-lang
tom025 has quit [Remote host closed the connection]
deens has quit [Ping timeout: 264 seconds]
bzalasky has joined #ruby-lang
bzalasky has quit [Remote host closed the connection]
|jemc| has joined #ruby-lang
deens has joined #ruby-lang
deens has quit [Read error: Connection reset by peer]
deens has joined #ruby-lang
mistym has joined #ruby-lang
deens has quit [Read error: Connection reset by peer]
kurko__ has joined #ruby-lang
deens has joined #ruby-lang
amclain has joined #ruby-lang
jsullivandigs has quit [Remote host closed the connection]
io_syl has quit [Ping timeout: 246 seconds]
deens has quit [Ping timeout: 252 seconds]
diegoviola has quit [Quit: WeeChat 0.4.2]
diegoviola has joined #ruby-lang
jsullivandigs has joined #ruby-lang
dorei has quit []
kurko__ has quit [Quit: Computer has gone to sleep.]
daikan_ has quit [Remote host closed the connection]
chouhoulis has joined #ruby-lang
jtw has joined #ruby-lang
chouhoulis has quit [Remote host closed the connection]
chouhoulis has joined #ruby-lang
kotk has quit [Ping timeout: 252 seconds]
yatish27 has joined #ruby-lang
kfpratt has quit [Remote host closed the connection]
kfpratt has joined #ruby-lang
kfpratt has quit [Ping timeout: 272 seconds]
Barrin6 has joined #ruby-lang
<|jemc|>
anyone have a pattern for setting up a string for interpolation, but delaying the interpolation until later (without using eval)
<bougyman>
"%s" % aProc
io_syl has joined #ruby-lang
<|jemc|>
and the proc returns an interpolation string in single quotes or something?
<|jemc|>
aProc = proc{'my string that uses #{x}'} ?
<|jemc|>
or were you just suggesting using format strings?
brettweavnet has joined #ruby-lang
io_syl has quit [Read error: Connection reset by peer]
chouhoulis has quit [Remote host closed the connection]
jay_m is now known as zz_jay_m
<|jemc|>
looks like there may be no simple facilities for doing what I want
brianpWins has joined #ruby-lang
brettweavnet has quit [Client Quit]
brianpWins has quit [Client Quit]
brettweavnet has joined #ruby-lang
r0bgleeson has quit [Ping timeout: 272 seconds]
diegoviola has quit [Ping timeout: 260 seconds]
yatish27 has quit [Remote host closed the connection]
diegoviola has joined #ruby-lang
deens has joined #ruby-lang
<|jemc|>
I was hoping to do arbitrary operations on objects in the string interpolations, which is more than format strings can do. But any kind of delayed interpolation that evaluates an expression based on a string is already a conceptual kind of eval. So because I'm not comfortable using eval here, I shouldn't be comfortable with that either.
yfeldblum has quit [Remote host closed the connection]
presidentbeef has quit [Quit: Page closed]
deens has quit [Ping timeout: 265 seconds]
jeff_r has joined #ruby-lang
ledestin has joined #ruby-lang
cored has quit [Ping timeout: 252 seconds]
diegovio1 has joined #ruby-lang
jeff_r has quit [Client Quit]
diegovio1 has quit [Changing host]
diegovio1 has joined #ruby-lang
diegoviola has quit [Ping timeout: 248 seconds]
kurko__ has joined #ruby-lang
amerine has quit [Ping timeout: 260 seconds]
kurko______ has joined #ruby-lang
amerine has joined #ruby-lang
mistym has quit [Remote host closed the connection]
diegovio1 is now known as diegoviola
lsegal has joined #ruby-lang
kurko__ has quit [Ping timeout: 260 seconds]
quizzicol has quit [Quit: Leaving.]
yatish27 has joined #ruby-lang
amerine has quit [Ping timeout: 248 seconds]
amerine has joined #ruby-lang
quizzicol has joined #ruby-lang
simi has joined #ruby-lang
tylersmith has joined #ruby-lang
quizzicol has quit [Ping timeout: 252 seconds]
mistym has joined #ruby-lang
yatish27 has quit [Remote host closed the connection]
daikan has joined #ruby-lang
quizzicol has joined #ruby-lang
tylersmith has quit []
tylersmith has joined #ruby-lang
daikan has quit [Ping timeout: 265 seconds]
mannyt has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
yfeldblum has joined #ruby-lang
yfeldblum has quit [Remote host closed the connection]
<|jemc|>
ah, sorry, I missed a more fundamental flaw there although my first point was also important
<|jemc|>
so, yes, in ruby, the object can call methods on itself by omitting the "self" as you've done
mykoweb has joined #ruby-lang
<Lewix>
ah
<Lewix>
that
<Lewix>
thanks!
<|jemc|>
so 'self.empty?' can be called with simply: 'empty?'
deens has joined #ruby-lang
<|jemc|>
but the same is _not_ true for attr_writer methods
<|jemc|>
or more generally, methods that end in =
<|jemc|>
so you can't leave off the self on self.customers=[]
<|jemc|>
because ruby thinks you're trying to create a local var called customers
bzalasky has quit [Remote host closed the connection]
<Lewix>
that
<Lewix>
that's right. i was aware of it. thanks for pointing that out
<|jemc|>
no problem
<Lewix>
|jemc|: any suggestion on how to refactor it
<|jemc|>
well, you can use self.customers = []
<|jemc|>
or you can use @customers = []
<|jemc|>
some people prefer to use the self. route because they like to make sure it goes through their writer method in case they ever want to replace attr_accessor with something nontrivial
<|jemc|>
like something that validates before setting, for example
<|jemc|>
they could override the customers= method with something nontrivial without changing any other code
<Lewix>
i meant the code in general
<Lewix>
=)
<|jemc|>
ha
<Lewix>
im sure theres a fair amount of refactoring that can be done. it smells metaprograming?
<|jemc|>
well it looks like you're not rearranging or validating the row values at all before passing them to the Customer.new method, is that right?
deens has quit [Ping timeout: 264 seconds]
<|jemc|>
if so, you can forego unpacking all of them by name just to pack them back in
<|jemc|>
customers << Customers.new(*row)
<|jemc|>
then you could do your one unpacking of the array in the Customers#initialize method
<|jemc|>
def initialize *values
<|jemc|>
@cust_id, @elect_or_gas, ... = values
<|jemc|>
end
<Lewix>
omg
<Lewix>
why dont i see those things as fast
<Lewix>
thanks =)
<|jemc|>
no problem
<|jemc|>
good luck :)
<Lewix>
one more thing
<Lewix>
theres a way to grap data without naming the variable and not knowing the data im grabbing.
<Lewix>
1.Is it a good thing? 2.How would you go about it?
<|jemc|>
I don't quite follow your description
<Lewix>
|jemc|: ok just give me a few minutes, I'll try to implement it
huma has joined #ruby-lang
diegovio1 has joined #ruby-lang
diegovio1 has quit [Changing host]
diegovio1 has joined #ruby-lang
diegoviola has quit [Ping timeout: 260 seconds]
daikan has joined #ruby-lang
hahuang61 has joined #ruby-lang
havenwood has quit [Remote host closed the connection]
r0bgleeson has joined #ruby-lang
vlad_starkov has joined #ruby-lang
rippa has joined #ruby-lang
daikan has quit [Ping timeout: 272 seconds]
sepp2k has quit [Read error: Connection reset by peer]
vlad_starkov has quit [Read error: Connection reset by peer]
havenwood has joined #ruby-lang
rahul_j has joined #ruby-lang
havenwood has quit [Read error: Connection reset by peer]
<Lewix>
|jemc|: I was trying to think of way to dynamically set my variables name
<|jemc|>
maybe you're thinking of instance_variable_set(:@my_var, value)
diegovio1 is now known as diegoviola
hahuang61 has quit [Ping timeout: 252 seconds]
kurko__ has quit [Quit: Computer has gone to sleep.]
hahuang61 has joined #ruby-lang
charlies_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
yfeldblum has quit [Remote host closed the connection]
<Lewix>
|jemc|: is there a local_variable_set()
jtw has quit []
bzalasky has joined #ruby-lang
<|jemc|>
there is in the binding object
<|jemc|>
but unless it was a pre-existing variable, it doesn't outlive the inner binding
<|jemc|>
also, did not exist before 2.1, if you're using something earlier
<|jemc|>
in other words, you probably can't do what you were hoping to do
<|jemc|>
you also can't create local vars from an eval
<|jemc|>
same issue - they do not outlive the inner binding that eval uses
yfeldblum has joined #ruby-lang
hahuang65 has joined #ruby-lang
hahuang61 has quit [Ping timeout: 245 seconds]
Cakey has quit [Ping timeout: 260 seconds]
Cakey has joined #ruby-lang
mistym has joined #ruby-lang
spuk has joined #ruby-lang
bzalasky has quit [Remote host closed the connection]
d4rkr4i has joined #ruby-lang
mistym has quit [Ping timeout: 272 seconds]
jsullivandigs has quit [Remote host closed the connection]
Barrin6 has quit [Quit: Leaving]
yatish27 has quit [Remote host closed the connection]
AKASkip has joined #ruby-lang
yatish27 has joined #ruby-lang
daikan has joined #ruby-lang
daikan has quit [Read error: Connection reset by peer]
<yorickpeterse>
no strict requirement for RVM there
<yorickpeterse>
Also what I meant was in terms of the features you'd require
<postmodern>
hopkins83, it is a fallacy that the entire community should use one and only one tool
yfeldblum has joined #ruby-lang
<yorickpeterse>
e.g. do you need gemsets, do you need a complex mounting sytstem, etc
<yorickpeterse>
or do you just want to install a Ruby and be done with it?
<postmodern>
also do you use a old/odd OS that needs help compiling ruby on?
quizzicol has joined #ruby-lang
<hopkins83>
yorickpeterse: Yes I need one gemset per app. What do you mean by complex mounting system?
* imperator
guesses separate filesystem
<hopkins83>
postmodern: I use OpenBSD. It's been a lot of compile issue but the RVM author took care of everything.
mbj has quit [Read error: Operation timed out]
<hopkins83>
Well, OpenBSD is split up into multiple partitions with different permissions, but all of my apps are in /home/some_app1/, /home/some_app2/ etc.
<yorickpeterse>
hopkins83: `rvm mount`
<postmodern>
hopkins83, you should consider using bundler, if you have one gemset per app
danijoo has quit [Read error: Connection reset by peer]
<postmodern>
hopkins83, gemsets are more for global sets of gems you switch between
<hopkins83>
postmodern: Cool thanks
<postmodern>
hopkins83, plus rubygems 2.2.0 now supports installing from the Gemfile
yfeldblum has quit [Ping timeout: 272 seconds]
danijoo has joined #ruby-lang
<hopkins83>
Sweet
vlad_sta_ has quit [Remote host closed the connection]
vlad_starkov has joined #ruby-lang
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
quizzicol has quit [Ping timeout: 252 seconds]
<imperator>
joast, ping
<darix>
postmodern: is 2.2.0 in ruby 2.1?
Johz has quit [Quit: Leaving]
Johz has joined #ruby-lang
mistym has joined #ruby-lang
ItSANg___ has quit [Quit: Leaving...]
mbj has joined #ruby-lang
mucker has joined #ruby-lang
mistym has quit [Ping timeout: 272 seconds]
Cakey has joined #ruby-lang
quizzicol has joined #ruby-lang
quizzicol1 has joined #ruby-lang
quizzicol has quit [Read error: Connection reset by peer]
ItSANgo has joined #ruby-lang
Cakey has quit [Ping timeout: 260 seconds]
ItSANgo has quit [Client Quit]
diegoviola has quit [Quit: WeeChat 0.4.2]
quizzicol1 has quit [Ping timeout: 260 seconds]
<Jacky>
\o/
ItSANgo has joined #ruby-lang
Dernise has joined #ruby-lang
huma has quit [Ping timeout: 260 seconds]
yatish27 has quit [Remote host closed the connection]
quizzicol has joined #ruby-lang
patriciomacadden has joined #ruby-lang
Dernise has quit [Quit: This computer has gone to sleep]
bin7me has quit [Quit: Leaving]
mbj has quit [Read error: Connection reset by peer]
Dernise has joined #ruby-lang
yfeldblum has joined #ruby-lang
<postmodern>
darix, why yes it is
<darix>
postmodern: was just curios. thank you
quizzicol has quit [Quit: Leaving.]
canton7 has joined #ruby-lang
yfeldblum has quit [Ping timeout: 246 seconds]
vlad_sta_ has joined #ruby-lang
daikan has quit [Read error: Connection reset by peer]
daikan_ has joined #ruby-lang
vlad_starkov has quit [Ping timeout: 260 seconds]
jerrytgarcia has joined #ruby-lang
dernise_ has joined #ruby-lang
simi has quit [Ping timeout: 246 seconds]
Dernise has quit [Ping timeout: 252 seconds]
mbj has joined #ruby-lang
quizzicol has joined #ruby-lang
mykoweb has joined #ruby-lang
quizzicol has quit [Ping timeout: 272 seconds]
dernise_ has quit [Quit: This computer has gone to sleep]
Cakey has joined #ruby-lang
dernise_ has joined #ruby-lang
Cakey has quit [Ping timeout: 248 seconds]
quizzicol has joined #ruby-lang
fijimunkii has joined #ruby-lang
sepp2k has joined #ruby-lang
red_menace has joined #ruby-lang
dernise_ has quit [Quit: This computer has gone to sleep]
francisfish has quit [Remote host closed the connection]
quizzicol1 has joined #ruby-lang
mbj has quit [Ping timeout: 248 seconds]
quizzicol has quit [Read error: Connection reset by peer]
DEac- has quit [Read error: Connection reset by peer]
thmzlt has joined #ruby-lang
achru_ has quit [Remote host closed the connection]
simi has joined #ruby-lang
quizzicol1 has quit [Ping timeout: 260 seconds]
mbj has joined #ruby-lang
kotk has joined #ruby-lang
rahul_j has quit [Quit: rahul_j]
Lewix has joined #ruby-lang
marcel has joined #ruby-lang
brettweavnet has quit [Read error: Connection reset by peer]
fijimunkii has quit [Ping timeout: 260 seconds]
fijimunkii has joined #ruby-lang
rahul_j has joined #ruby-lang
yfeldblum has joined #ruby-lang
patriciomacadden has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
foucist has joined #ruby-lang
<foucist>
any idea how to handle multiple regexp w/ diff substitutions on a string? can't chain gsubs
<MrZYX>
now your outer maps in 85, 92, 98 want to be eachs (and get some newlines)
<MrZYX>
and customer.data.map { |item| item.to_s.center 15}.join'|' is redundant, make it a method
<MrZYX>
def format_customer customer
mykoweb has joined #ruby-lang
<MrZYX>
customer.elect_or_gas == "1" && customer.elect_or_gas != "2" feels redundant too, it can't be "2" if it's "1" already
thmzlt has quit [Remote host closed the connection]
thmzlt has joined #ruby-lang
yfeldblum has joined #ruby-lang
<MrZYX>
and a good technique is to extract magic values into constants
yorickpeterse has quit [Read error: Connection reset by peer]
godman has joined #ruby-lang
godman has quit [Remote host closed the connection]
<MrZYX>
like the 15 you pass to center but also the "1" and "2" for elect_or_gas
yorickpeterse has joined #ruby-lang
<Lewix>
MrZYX: thanks that's a lot of information and certainly help. I'm reading about struct.new atm
wallerdev has quit [Quit: wallerdev]
<MrZYX>
though another way to make those more obvious is to map them to :electricity and :gas and name the attribute type or something
thmzlt has quit [Remote host closed the connection]
<MrZYX>
or even just adding gas? and electricity? to your customer class
daikan has joined #ruby-lang
thmzlt has joined #ruby-lang
daikan_ has quit [Read error: Connection reset by peer]
<MrZYX>
line 57 is just yaml.puts YAML.dump(c.data), no? (we use . to call methods. always)
yfeldblum has quit [Ping timeout: 272 seconds]
<Lewix>
MrZYX: you're faster than a speeding bullet. thank you ill make the fix you recommended and get back at you
<MrZYX>
also having a yaml file consisting of multiple yaml files seems odd, just build a nested array and dump it in one go, or yet better build an array of hashes
thmzlt has quit [Ping timeout: 252 seconds]
<MrZYX>
finally just a style thing: customers.uniq {|customer| customer.cust_id } can be written as customers.uniq(&:cust_id), if you decide to have gas? and electricity? methods on your customer class you can then also do customers.select(&:gas?) etc
<ddd>
mrzyx TIL. didn't know that myself
<Lewix>
MrZYX: you also mentioned something about the code - that it should be more modular. You would create three classes, or 2 modules and one class
<MrZYX>
I see three concerns, so three classes
<ddd>
never seen that access style for methods on an object (@obj.select(&:gas)
<MrZYX>
well four in total since you already have two classes
<ddd>
how would you push params to the called method?
<MrZYX>
ddd: you don't
<ddd>
so you would use that for methods not taking params then. ok good to know
<ddd>
how does that differ from, and does it involve method_missing at all, calling send
<MrZYX>
it works this way: the & operator calls .to_proc on the argument before trying to convert it to a block, Symbol#to_proc is implemented much like this: proc {|e| e.send(self) }
AKASkip has joined #ruby-lang
hahuang61 has joined #ruby-lang
Onixs has quit [Read error: Connection reset by peer]
vlad_sta_ has quit [Remote host closed the connection]
<Lewix>
MrZYX: here is another version of my code ill have to update too after making the changes your recommended
<ddd>
self being the proc obj, or e. there? (I get confoozled occasionally on what object would be in scope when self is called)
<Lewix>
MrZYX: the dynamic version
<MrZYX>
ddd: Symbol#to_proc, so it's the symbol ;)
<ddd>
got it. thanks for the explanation.
Onixs has joined #ruby-lang
<ddd>
interesting way to call it. i don't think i'd have ever thought of calling in that manner, myself, if i hadn/t seen it done
<ddd>
any particular use cases for this particular style of method calling?
<MrZYX>
File.readlines.map(&:strip)
<MrZYX>
for example
<MrZYX>
stuff like that
<ddd>
sorry for drilling, i've not seen this before like i said, so trying to educate myself while someone who knows this usage pattern is around :)
<MrZYX>
no worries
<ddd>
yeah i've seen map
<ddd>
well seen its use *with* map
<MrZYX>
inject even does the & for you: sum = [1,2,3].inject(:+)
<ddd>
implied with the :+ then?
<Lewix>
does the channel have a logger
<ddd>
hehe hope so. this is a tidbit i'd like to keep, and i don't log on this client
<Lewix>
me neither
<ddd>
totally a throwaway shell so i don't waste time with logs on here
<r0bgleeson>
Lewix: I see, you shouldn't have to do anything special there. X = Struct.new(:foo, :bar); X.new(*["1", "2"]).foo => "1"
<r0bgleeson>
Lewix: what is the problem you are having?
achru has joined #ruby-lang
<r0bgleeson>
Lewix: I don't know why I made that so complicated, sorry, X.new(1,2)
<Lewix>
r0bgleeson: after refactoring, it is not working properly. The output of the show_ methods is blank
<r0bgleeson>
okay
<r0bgleeson>
the first gist is the code thats not working?
<Lewix>
r0bgleeson: that's right. And the second gist is the old code that works
<r0bgleeson>
'w' is going to overwrite the file everytime
<r0bgleeson>
are you creating the file on every run of this script?
<r0bgleeson>
i don't see serialize_users being called.
kurko_ has quit [Quit: Computer has gone to sleep.]
<Lewix>
r0bgleeson: I'm not calling it yet.
<r0bgleeson>
alright, is the file you're reading populated?
MrZYX is now known as MrZYX|off
<r0bgleeson>
this: ./pulse_data.txt
<Lewix>
it is =)
<Lewix>
give me a sec. i paste the output
MrZYX|off is now known as MrZYX
<r0bgleeson>
dont do that
<r0bgleeson>
it looks like you dont want to share that data
<r0bgleeson>
can you remove your implementation of #initialize on Struct?
<r0bgleeson>
its not neccessary
MrZYX is now known as MrZYX|off
<r0bgleeson>
all of your fields are nil
<r0bgleeson>
the only one you populate is 'data'
<r0bgleeson>
cust_id etc are never given values
<r0bgleeson>
because you override #initialize to ignore everything but 'data'
<Lewix>
ahhhh
<Lewix>
r0bgleeson: I needed to do that because i use data later in the code
<Lewix>
it makes sense now - it's overwritting
<r0bgleeson>
yeah, none of your other fields are set
<r0bgleeson>
everything would be nil but 'data'
GaelanAintAround has quit [Ping timeout: 252 seconds]
zz_dlu has quit [Ping timeout: 245 seconds]
<Lewix>
r0bgleeson: is there a good way to still initialize an instance variable data with struct at initialization time or I should just go back to using class
<Lewix>
(without overwritting anything else)
zz_dlu has joined #ruby-lang
<r0bgleeson>
when you pass data, is there a single argument to the struct?
<r0bgleeson>
what are you using data for?
benlovell has quit [Ping timeout: 264 seconds]
<r0bgleeson>
you can super(*fields) on the following line
<r0bgleeson>
i just dont understand what 'data' is or why youre using that in place of populating the fields on the struct
<Lewix>
r0bgleeson: everything after line 70 use data to output
<r0bgleeson>
okay
GaelanAintAround has joined #ruby-lang
<r0bgleeson>
data looks like a regular field
<r0bgleeson>
why are you treating it differently?
<Lewix>
r0bgleeson: i just needed a variable that contains all the fields
mykoweb has quit [Remote host closed the connection]
<r0bgleeson>
i see
<r0bgleeson>
you dont need to do that
<r0bgleeson>
do you want the fields name?
mykoweb has joined #ruby-lang
achru has quit [Remote host closed the connection]
hahuang61 has joined #ruby-lang
<r0bgleeson>
or their values?
<r0bgleeson>
looks like the values
<Lewix>
values
<r0bgleeson>
hang on
<Lewix>
and by the way super(*fields) is not working either (weird)
bzalasky has quit [Remote host closed the connection]
mykoweb_ has joined #ruby-lang
mykoweb has quit [Read error: Connection reset by peer]
atmosx has joined #ruby-lang
mistym has joined #ruby-lang
<r0bgleeson>
Lewix: just use to_a for that
<r0bgleeson>
remove data
<r0bgleeson>
X = Struct.new(:foo, :bar); X.new(*["1", "2"]).to_a
<r0bgleeson>
(pry):7: warning: already initialized constant X
<r0bgleeson>
=> ["1", "2"]
daikan has joined #ruby-lang
hahuang61 has quit [Ping timeout: 245 seconds]
<r0bgleeson>
then you can remove initialize altogether
<r0bgleeson>
and just use to_a when you need what was 'data'
<Lewix>
r0bgleeson: wow
<Lewix>
r0bgleeson: you guys never cease to impress me
<Lewix>
r0bgleeson: thank you
<r0bgleeson>
ok cool, no problem
<Xuisce>
hi Lewix
<Lewix>
r0bgleeson: was there another way to do it with def initialize - out of curiosity
<Lewix>
hi Xuisce
<Xuisce>
heya
<Xuisce>
I think your a op in ##english right?
<Xuisce>
hm
mistym has quit [Ping timeout: 272 seconds]
<r0bgleeson>
Lewix: yeah, you could have said: Customer.new(*fields, fields)
<Xuisce>
c/lear
toretore has quit [Quit: This computer has gone to sleep]
<r0bgleeson>
you wouldn't have needed #initialize for that case either
<yorickpeterse>
Today is a slow day
<yorickpeterse>
not nearly enough happening on the Githubs
<r0bgleeson>
it is indeed a slow day
<Lewix>
r0bgleeson: I don't understand, it's not quite clear
<Lewix>
Xuisce: more or less
francisfish has joined #ruby-lang
<r0bgleeson>
Lewix: 'fields' is all the values of the struct, except 'data', the last value is an array of every value, or data, or the last member of the struct
<r0bgleeson>
so you could have just passed all the values as the last argument
<Lewix>
r0bgleeson: lol
<Xuisce>
Lewix: care for a pm ?
<Lewix>
r0bgleeson: that's ridiculous. thank you
<Lewix>
Xuisce: ok?
<Xuisce>
thanks
jerrytgarcia has joined #ruby-lang
mehlah has joined #ruby-lang
mbj has joined #ruby-lang
vlad_starkov has quit [Remote host closed the connection]
<Lewix>
r0bgleeson: why is that storing an array of hashes better than a list of arrays?
vlad_starkov has joined #ruby-lang
<Lewix>
(more efficient)
<r0bgleeson>
where do you see an array of hashes?
<r0bgleeson>
to_a should return every value
<r0bgleeson>
in the struct
<r0bgleeson>
if its returning hash's then you may be using that as the value
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<Lewix>
11:39 MrZYX: also having a yaml file consisting of multiple yaml files seems odd, just build a nested array and dump it in one go, or yet better build an array of hashes
<Lewix>
r0bgleeson: ^^
<r0bgleeson>
i don't know how the YAML file looks, it seems fine to me
<r0bgleeson>
if you are trying to represent multiple documents in a single document then an array of hashes may make sense.
<Lewix>
r0bgleeson: would you consider deflation part of parsing
<r0bgleeson>
oh i see
<r0bgleeson>
yeah
<r0bgleeson>
thats not very good
<r0bgleeson>
there's a few strange things going on there
<r0bgleeson>
you're using CSV to wrie a file called .yaml
<r0bgleeson>
if you were to use YAML, it can represent your struct just fine
hamiljs has quit [Ping timeout: 246 seconds]
<r0bgleeson>
so you could dump an array of customers
<r0bgleeson>
but, that means if someone ever compromised your YAML file, they may be able to load code into your program
<r0bgleeson>
so a plain-text format that isnt as powerful as YAML could be better
<r0bgleeson>
maybe JSON
<r0bgleeson>
so an array of hashes
<Lewix>
I'm thinking about moving my method serialize_users to the reporting class
quizzicol has joined #ruby-lang
<r0bgleeson>
yeah
<r0bgleeson>
id rename the file you create as well, its not yaml atm
<r0bgleeson>
probably better to not be yaml as well
<Lewix>
oh that was an oversight of my part. I used yaml until MrZYX|off suggested txt
<ljarvis>
hi
<r0bgleeson>
yeah
<r0bgleeson>
good call
<r0bgleeson>
CSV seems fine
<r0bgleeson>
works well for creating new struct's
<r0bgleeson>
very little work to do for read/write
<r0bgleeson>
Lewix: it shouldn't, every customer should be a row, which is an array of strings. you can read the file, map through each, and create an instance of Customer. write is just iterate and call to_a for each row
Barrin6 has quit [Read error: Connection reset by peer]
<r0bgleeson>
Lewix: so your write should be something like, csv << customer.to_a
<ljarvis>
gotta rewrite everything
<r0bgleeson>
read is something like, rows.map { |row| Customer.new(row) }
<Lewix>
r0bgleeson: thanks. ill work on it again after lunch
<r0bgleeson>
cool
daikan has quit [Remote host closed the connection]
mistym has joined #ruby-lang
jstemmer has quit [Ping timeout: 252 seconds]
jstemmer has joined #ruby-lang
<ljarvis>
in node js
tsou has joined #ruby-lang
<r0bgleeson>
thats wise
<apeiros>
/kick ljarvis no hipsters allowed
chouhoulis has joined #ruby-lang
<ljarvis>
apeiros: you might want to kick *
<r0bgleeson>
i wear blue jeans
<r0bgleeson>
cuz i like to generalize
MrZYX|off is now known as MrZYX
lsegal has joined #ruby-lang
<yorickpeterse>
node.js is so 2013
<yorickpeterse>
Elixir is the next big thing
<ljarvis>
I played with elixir
<r0bgleeson>
elixir looks interesting
<yorickpeterse>
I run a startup that focuses on disrupting the cat litter industry by providing cat litter in the cloud
<yorickpeterse>
we use Elixir for it
<ljarvis>
derp
<ljarvis>
better use haskell
<r0bgleeson>
i think it's probably a bad idea because it has too much familiarity (in syntax) with ruby, and in that case it may just be better to learn erlang
<r0bgleeson>
thats just for me, an erlang programmer may find the inverse to be true
<ljarvis>
i dunno, i think it's far enough from ruby once you dive into it
<r0bgleeson>
i didnt learn haskell, but banister did or tried to
<yorickpeterse>
apeiros: except Ada is actually used
<r0bgleeson>
in the course of that i learnt about partial application
<r0bgleeson>
which is cool to learn about and apply in ruby
<apeiros>
yorickpeterse: s/except//
<ljarvis>
ima be writing f# over here
<r0bgleeson>
so even if you cant use it for anything real, it can be nice to steal ideas from
heftig has quit [Ping timeout: 245 seconds]
<r0bgleeson>
Ada is as niche as haskell, id guess
mykoweb_ has quit [Remote host closed the connection]
<yorickpeterse>
I believe Ada is quite heavily used in the aero/space industry
mykoweb has joined #ruby-lang
<r0bgleeson>
it is
<r0bgleeson>
thats where i heard it being used as well
<r0bgleeson>
military/army/embedded devices
<r0bgleeson>
pretty niche
francisfish has quit [Remote host closed the connection]
mykoweb has quit [Ping timeout: 260 seconds]
jerrytgarcia has quit [Ping timeout: 272 seconds]
francisfish has joined #ruby-lang
francisfish has quit [Remote host closed the connection]
achru has joined #ruby-lang
rahul_j has quit [Quit: rahul_j]
Lewix_ has joined #ruby-lang
stonerfish has joined #ruby-lang
Lewix has quit [Remote host closed the connection]
vlad_sta_ has joined #ruby-lang
vlad_starkov has quit [Ping timeout: 252 seconds]
anekos__ has quit [*.net *.split]
Rickmasta has quit [*.net *.split]
x0f has quit [*.net *.split]
Senjai has quit [*.net *.split]
rue has quit [*.net *.split]
Jacky has quit [*.net *.split]
hopkins83 has quit [*.net *.split]
wmoxam has quit [*.net *.split]
eval-in has quit [*.net *.split]
soahccc has quit [*.net *.split]
joast has quit [*.net *.split]
hachiya has quit [*.net *.split]
djinni` has quit [*.net *.split]
tpope has quit [*.net *.split]
drollwit has joined #ruby-lang
quizzicol has joined #ruby-lang
hopkins83 has joined #ruby-lang
anekos__ has joined #ruby-lang
Rickmasta has joined #ruby-lang
x0f has joined #ruby-lang
Senjai has joined #ruby-lang
Jacky has joined #ruby-lang
rue has joined #ruby-lang
wmoxam has joined #ruby-lang
eval-in has joined #ruby-lang
soahccc has joined #ruby-lang
joast has joined #ruby-lang
hachiya has joined #ruby-lang
djinni` has joined #ruby-lang
tpope has joined #ruby-lang
x0f_ has joined #ruby-lang
quizzicol has quit [Ping timeout: 269 seconds]
Jacky has quit [Excess Flood]
x0f has quit [Ping timeout: 272 seconds]
phansch has quit [Quit: Leaving]
robbyoconnor has quit [Ping timeout: 252 seconds]
MrZYX is now known as MrZYX|off
jtw has joined #ruby-lang
Jacky has joined #ruby-lang
<yorickpeterse>
whitequark: OPEN SAUCE FOUNDRY ALREADY
<yorickpeterse>
I know you're reading this because you're on Github
<yorickpeterse>
also fuck me now I sound like a creeper
MrZYX|off is now known as MrZYX
hamiljs has quit [Ping timeout: 264 seconds]
hachiya has quit [Ping timeout: 272 seconds]
hachiya has joined #ruby-lang
VTLob has quit [Read error: Operation timed out]
sepp2k has quit [Read error: Connection reset by peer]
mykoweb has joined #ruby-lang
achru_ has joined #ruby-lang
achru has quit [Ping timeout: 252 seconds]
mykoweb has quit [Ping timeout: 260 seconds]
robbyoconnor has joined #ruby-lang
mucker has joined #ruby-lang
kotk has quit [Read error: Connection reset by peer]
Minimalist has joined #ruby-lang
mistym has quit [Remote host closed the connection]
vlad_sta_ has quit [Remote host closed the connection]
vlad_starkov has joined #ruby-lang
DouweM has quit [Read error: Connection reset by peer]
enebo has quit [Quit: enebo]
AKASkip has joined #ruby-lang
VTLob has joined #ruby-lang
achru_ has quit []
elia has joined #ruby-lang
arBmind has quit [Ping timeout: 260 seconds]
quizzicol has joined #ruby-lang
quizzicol has quit [Ping timeout: 252 seconds]
Minimalist has quit [Read error: Connection reset by peer]
CodeBunny has joined #ruby-lang
zer0ne has joined #ruby-lang
imjacobclark has joined #ruby-lang
<imjacobclark>
Can anybody give me any better insights into what the Rake file is for? For example, could I use the Rake file to automate the setup of an application, ie, demonise a service or configure a database, etc?
<|jemc|>
yeah, the Rakefile csn br used for any any automated task
<|jemc|>
but usually for building, testing, deploying, etc
<imjacobclark>
Ah I see cool, thanks!
<imjacobclark>
Could I get the rakefile to run 'bundle install'?
vlad_sta_ has joined #ruby-lang
<|jemc|>
of course
<CodeBunny>
absolutely
<|jemc|>
task :bundinst do
<|jemc|>
exec "bundle install"
<|jemc|>
end
<imjacobclark>
Ah! I see, so you run shell commands through exec?
<imjacobclark>
Fantastic!
vlad_sta_ has quit [Read error: Connection reset by peer]
<CodeBunny>
any cucumber or pageObject wiz's around
vlad_starkov has quit [Ping timeout: 264 seconds]
<|jemc|>
imjacobclark: running shell commands is a general ruby thing
<|jemc|>
rake is just a convenient way to specify a set of interdependent tasks
<imjacobclark>
Yeah, so I can specify a number of 'tasks' for example 'test' 'setup' 'deploy'
<imjacobclark>
For 'setup' I may have 'exec bundle install'
Elico has quit [Quit: Elico]
Elico has joined #ruby-lang
<CodeBunny>
dont you mean bundle exec install?
heftig has joined #ruby-lang
<|jemc|>
neh, he means exec "bundle install"
<imjacobclark>
yeah sorry
<imjacobclark>
I mean id run the command
<CodeBunny>
oh... right
<imjacobclark>
ruby = exec
<imjacobclark>
then
<imjacobclark>
bundle install
<imjacobclark>
> exec "bundle install"
<|jemc|>
and your tasks can call eachother by specifying prerequisite tasks
<|jemc|>
task :c => [:a, :b] do ... end
<|jemc|>
so c will also run a and b first
<imjacobclark>
I see, okay cool!
zer0ne has left #ruby-lang [#ruby-lang]
vlad_starkov has joined #ruby-lang
piyo has joined #ruby-lang
jerrytgarcia has joined #ruby-lang
hahuang61 has joined #ruby-lang
francisfish has joined #ruby-lang
_TheRev_ has joined #ruby-lang
drollwit has quit []
hahuang61 has quit [Ping timeout: 264 seconds]
francisfish has quit [Ping timeout: 272 seconds]
thmzlt has quit [Remote host closed the connection]
thmzlt has joined #ruby-lang
prc has joined #ruby-lang
sepp2k has joined #ruby-lang
<imjacobclark>
Whats the best way to execute RSpec tests from Rake?
Wardrop has joined #ruby-lang
jaska has joined #ruby-lang
jaska has left #ruby-lang [#ruby-lang]
piyo has left #ruby-lang ["ERC Version 5.3 (IRC client for Emacs)"]
MrZYX is now known as MrZYX|off
<Wardrop>
I want to inject local variables into a proc using Proc#binding.local_variable_set
quizzicol has joined #ruby-lang
gix has quit [Quit: Client exiting]
<Wardrop>
The problem is that Proc#binding is a copy of the binding, not the original binding, hence any changes made to it are not set against the proc
<Wardrop>
Can anyone think of any other creative ways of defining a local variable within a Proc AFTER it's been defined.
<apeiros>
I can't think of any reasonable use case
<apeiros>
the only one I can think of is templating, and that doesn't bother that you're using a copy
<Wardrop>
It's for a DSL
<apeiros>
yeah, well, let me put it this way: if you dynamically f'ck with lvars, you're doing it wrong™
gix has joined #ruby-lang
<Wardrop>
apeiros: I would almost always be of the same opinion. However, in this case the user is actually choosing the name of the local variable, it's just they're not putting it between the |a,b| portion of the block definition.
<Wardrop>
They're defining a "named capture" in the content of a web framework.
<Wardrop>
Any collisions with other local variables is of their own doing.
<Wardrop>
context* not content
<apeiros>
Wardrop: and how could the user potentially use the actual *local variable*?
<apeiros>
can the user inject code?
<Wardrop>
E.g. proc { puts hello }
<Wardrop>
I would then inject the local `hello` variable later before the proc is actually executed.
quizzicol has quit [Ping timeout: 260 seconds]
<Wardrop>
d
<Wardrop>
Here's a full example: get('/::id/::title') { p id, title }
<Wardrop>
Otherwise, the user either needs to repeat themselves: get('/::id/::title') { |id, title| p id, title }
MrZYX|off is now known as MrZYX
<Wardrop>
Or they need to use an accessor: get('/::id/::title') { p captures[:id], captures[:title] }
<apeiros>
Wardrop: id/title can also be methods
<apeiros>
maybe that helps
<Wardrop>
Indeed they could, but in this case the user deals with them in the same way they'd deal with Proc argument that collide with methods: `self.id` and `self.title`
<Wardrop>
Consider more like I'm defining the Proc arguments on behalf of the user
<Wardrop>
Consider it* more...
<Wardrop>
Oh sorry, you were suggesting a solution
<Wardrop>
The problem with that is that can legitimately override methods in the context the Proc is executed in.
<apeiros>
IMO the better solution would be to provide a proper object as argument: get(…) { |req| req.id, req.title }
<Wardrop>
Local variables is the nicest solution believe it or not
kotk has joined #ruby-lang
<apeiros>
I don't believe it
<Wardrop>
apeiros: Actually that's how it's currently done.
<Wardrop>
But in that case, it's generally easier to define anonymous captures like this: get('/*/*') { |id, title| p id, title }
<Wardrop>
I'm trying to make named captures less verbose