[Ironruby-core] Difficulties grasping generics + IronRuby - any idea? (OpenXML)
thibaut.barrere at gmail.com
Fri Nov 20 10:17:55 EST 2009
I'm testing out the OpenXML SDK with IronRuby (0.9.2). Turns out it's full
of generics in there, a good play field.
Here I'm trying to use the API to retrieve a list of sheets in an existing
I'm having a hard-time understanding why I can't call "b.first" in the next
snippet (full version at http://gist.github.com/239555):
doc = SpreadsheetDocument.open('docs/single-cell.xlsx', false)
a = doc.workbook_part.workbook.method(:get_first_child).of(Sheets).call
# -> DocumentFormat.OpenXml.Spreadsheet.Sheets
b = a.method(:elements).of(Sheet).call
# -> DocumentFormat.OpenXml.OpenXmlElementList+<OfType>d__0`1[DocumentFormat.OpenXml.Spreadsheet.Sheet]
# b.first or anything similar fails
It turns out that b.methods shows a "to_a" method is available, then I can
puts b.to_a.first # woot!
# -> DocumentFormat.OpenXml.Spreadsheet.Sheet
So my questions are:
- why can't I call b.first ? (maybe there's something obvious I didn't see -
I assume it's probably that)
- are there better ways of writing this ?
And if you are interested to follow (I really need to wrap some ruby sugar
around all this to make it easier to work with), I'll push my experiments
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironruby-core